I have a gmap with direction line displayed on it (2 or more points). Is there any way to get all points from map depending viewport (zoom level), only those that user can see ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I won’t give you the tea spoon version, but here is how you do it. First of all, make sure you have all your markers available in an array.
map.getBounds(). This will return aLatLngBoundsobject, which contains the coordinates of the bottom left point of your viewport as well as the top right part.marker.getPosition()and check if they are above and to the right of the map bounds south west point, as well as below and to the left of the map bounds north east point.That array now contains all the points in your viewport. Repeat as necessary.
More information can be found in the Google Maps API v3 reference