回答編集履歴

1

コメントに対する回答。

2016/12/15 16:48

投稿

kei344
kei344

スコア69407

test CHANGED
@@ -17,3 +17,43 @@
17
17
  ////ここでどのチェックボックスがチェックされているか確認 end
18
18
 
19
19
  ```
20
+
21
+
22
+
23
+ ---
24
+
25
+
26
+
27
+ **追記:**
28
+
29
+
30
+
31
+ jQueryで取得せずとも overlayadd / overlayremove イベントを採れば名前を取得することが出来ます。
32
+
33
+
34
+
35
+ 【Documentation - Leaflet - a JavaScript library for interactive maps】
36
+
37
+ [http://leafletjs.com/reference-1.0.2.html#map-event](http://leafletjs.com/reference-1.0.2.html#map-event)
38
+
39
+ > overlayadd LayersControlEvent Fired when an overlay is selected through the layer control.
40
+
41
+ > overlayremove LayersControlEvent Fired when an overlay is deselected through the layer control.
42
+
43
+
44
+
45
+ どなたかの作ったサンプル( http://jsfiddle.net/Xelio/FBSC8/ )が動かなかったので一部修正しました。とりあえず名前が取得できるところまではわかると思います。
46
+
47
+ [http://jsfiddle.net/txjm0soe/2/](http://jsfiddle.net/txjm0soe/2/)
48
+
49
+
50
+
51
+ ---
52
+
53
+
54
+
55
+ ```JavaScript
56
+
57
+ var html = $( '.leaflet-control-layers-selector:checked' ).parent().find( 'span' ).html()
58
+
59
+ ```