Display Markers which are within the current view port in Google Maps v3 js api

♀尐吖头ヾ 提交于 2019-12-23 03:57:11

问题


The Scenario

I have a few locations that I need to mark on the map. I can simply do this by marking everything at once, but since the number of locations that I need to mark will be huge, I want to handle it like this - When the users browse through the map, only the locations that are in the current view port will be Marked on the Map. Now, I can get the NE and SW bounds of the map using the getNorthEast() and getSouthWest() functions of the google.maps.LatLngBounds class. We can use the contains() function to find out if a location is in the view port, but again, since the number of location is large, it will slow down the browser, So i am planning to do it in the backend using Ajax.

I am planning to hit Ajax using the idle event listener and pass in the NE and SW co-ordinates and in the backend, find the locations that are within that bound and send it to the front end to display on the map.

The Problem

I am using PHP in the backend and MySQL as Database, how do I find if a given co-ordinate is within the rectangle that is formed by the co-ordinates(NE co-ordinate of the viewport and SW co-ordinate of the viewport) that I have provided?

来源:https://stackoverflow.com/questions/33493334/display-markers-which-are-within-the-current-view-port-in-google-maps-v3-js-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!