Determine if point is within bounding box

后端 未结 7 1940
没有蜡笔的小新
没有蜡笔的小新 2020-12-08 11:02

How would you determine if a given point is within the bounding box?

My point is 48.847172 , 2.386597.

Boundingbox:

    \"48.7998602295\",
           


        
7条回答
  •  误落风尘
    2020-12-08 11:53

    If you are using leaflet, you can create a new LatLngBounds and use its contains() operation:

    var bounds = new L.LatLngBounds(
     new L.LatLng(gc.bbox['_northEast'].lat, gc.bbox['_northEast'].lng),
     new L.LatLng(gc.bbox['_southWest'].lat, gc.bbox['_southWest'].lng));
    
    return bounds.contains(new L.LatLng(pos.latitude, pos.longitude))
    

提交回复
热议问题