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?