Reputation: 2219
I am using http://code.google.com/p/jquery-ui-map/
I am trying to find a way when looping through markers, of finding out if the markers are visible within the current viewport.
Does anybody know how to do this. I have tried isVisible()
Upvotes: 1
Views: 1017
Reputation: 927
In the beta version there is a inViewport, see jquery google maps plugin filter by property
Upvotes: 0
Reputation: 59435
Don't know about jquery-ui-map, but in the raw google maps api v3 it's fairly simple:
var bnd = map.getBounds();
var ne = bnd.getNorthEast();
var sw = bnd.getSouthWest();
var pos = marker.getPosition();
if (pos.lat() >= sw.lat() && pos.lat() <= ne.lat() &&
pos.lng() >= sw.lng() && pos.lng() <= ne.lng()) { // marker is in view
....
}
Upvotes: 1