回答編集履歴
1
情報の追加。
test
CHANGED
@@ -1 +1,71 @@
|
|
1
1
|
`onEachFeature` 内で `markers.push(layer);` してリンク先のように処理してみればよいのでは?
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
**追記:**
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
```JavaScript
|
16
|
+
|
17
|
+
var markers = [];
|
18
|
+
|
19
|
+
$.getJSON( "/geo_json" ).done( function( data ) {
|
20
|
+
|
21
|
+
var geojson = L.geoJson( data, {
|
22
|
+
|
23
|
+
onEachFeature: function ( feature, layer ) {
|
24
|
+
|
25
|
+
layer.bindPopup( feature.properties.popupContent );
|
26
|
+
|
27
|
+
},
|
28
|
+
|
29
|
+
pointToLayer: function (feature, latlng) {
|
30
|
+
|
31
|
+
var m = L.marker( latlng, { title : feature.properties.popupContent } );
|
32
|
+
|
33
|
+
markers.push( m );
|
34
|
+
|
35
|
+
return m;
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
});
|
40
|
+
|
41
|
+
geojson.addTo( map );
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
function markerFunction( id ) {
|
46
|
+
|
47
|
+
for ( var i in markers ) {
|
48
|
+
|
49
|
+
var markerID = markers[i].options.title;
|
50
|
+
|
51
|
+
if ( markerID == id ) {
|
52
|
+
|
53
|
+
markers[i].openPopup();
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
$("a").click(function(){
|
62
|
+
|
63
|
+
markerFunction( $( this )[0].id );
|
64
|
+
|
65
|
+
});
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
});
|
70
|
+
|
71
|
+
```
|