How can I check the marker is or isn't in the bounds using google maps v3

前端 未结 1 1964
臣服心动
臣服心动 2020-12-08 02:32

This is my code, I think it may has some mistakes:

        var bounds_array;
        google.maps.event.addListener(map,\'bounds_changed\', function (){
              


        
相关标签:
1条回答
  • 2020-12-08 02:53

    The LatLngBounds object comes with a contains() method which takes a LatLng point and returns true if the point happens to be within the bounds, or false if outside.

    Therefore, what about something like the following?

    function check_is_in_or_out(marker){
      return map.getBounds().contains(marker.getPosition());
    }
    
    0 讨论(0)
提交回复
热议问题