0
私の例では、マーカーがバウンディングボックス内にあるかどうかを確認しようとしています。そうである場合、ポップアップテキストはtrueに設定されます。リーフレットでマーカーがバウンディングボックスにあるかどうかを確認する方法
私は "L.latlngBounds"は関数ではありません。 誰かが正しい方向に私を向けることができるだろうか?
checkBounds = (marker) ->
if L.latlngBounds(inBounds).contains(currentMarker.getLatLng())
return "True"
else
return "False"
map = L.map('mapid').setView([
51.505
-0.09
], 13)
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors').addTo map
neCorner = L.marker([47.6349, -122.3206])
swCorner = L.marker([47.6341, -122.3211])
currentMarker = L.marker([47.6345, -122.3208])
inBounds = new L.featureGroup([swCorner, neCorner])
map.fitBounds(inBounds.getBounds(), { padding: [50, 50] })
currentMarker.addTo(map).bindPopup(checkBounds(currentMarker)).openPopup()
更新 はコメントでコードを投稿する方法を見つけ出すことができなかったので、私は
checkBounds = (marker) ->
if L.latLngBounds([swCorner, neCorner]).contains(marker)
return "True"
else
return "False"
map = L.map('mapid').setView([
51.505
-0.09
], 13)
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors').addTo map
neCorner = L.latLng([47.6349, -122.3206])
swCorner = L.latLng([47.6341, -122.3211])
currentMarker = L.latLng([47.6355, -122.3208])
map.fitBounds(([swCorner, neCorner]), { padding: [50, 50] })
L.marker(currentMarker).addTo(map).bindPopup(checkBounds(currentMarker)).openPopup()
私が得たそれらの新しいプログレッシブレンズは、私が彼らがそうであると思ったほど良くないと思います。 :) TOTALLYは "L"を逃した。ありがとう。気にする人のために、新しいコードは次のように読んでいます: – Ben
は@alexを追加するべきですが、私がバックアップしようとしていたときに面白いことをしました。 – Ben