Reputation: 153
I know how to use an overlay projection to get a LatLng object, and then convert that single LatLng to pixels, using .fromLatLngToDivPixel()
However, .getBounds() returns a pair of LatLng coordinates. I've tried accessing it like it's an array (as in specifying index[1] for example) but that does not work. It doesn't seem to be an array.
Is there a way to convert the value from .getBounds() to pixel data?
Upvotes: 6
Views: 11418
Reputation: 9407
However, .getBounds() returns a pair of LatLng coordinates. I've tried accessing it like it's an array (as in specifying index1 for example) but that does not work. It doesn't seem to be an array.
LatLngBounds is not an array, it's an object and the documentation shows you two methods to get the coordinates:
var NE = bounds.getNorthEast();
var SW = bounds.getSouthWest();
Those two methods return LatLng objects which you can pass to fromLatLngToDivPixel()
However, if you got your LatLngBounds object by reading map.getBounds()
then you already know what the pixel values should be, (the corners of your map container DIV).
Upvotes: 12