>From a Google Maps pro I was told, that this is a general problem
(also with the JavaScript API).
So I came up with this dirty solution:
map.setZoom(map.getBoundsZoomLevel(directions.bounds));
var markerWidth:int = 50;
var markerHeight:int = 50;
var startMarkerPoint:Point =
map.fromLatLngToViewport(startMarker.getLatLng());
var endMarkerPoint:Point =
map.fromLatLngToViewport(endMarker.getLatLng());
var maxMarkerBounds : Rectangle = new Rectangle(
Math.min(startMarkerPoint.x, endMarkerPoint.x) - markerWidth,
Math.min(startMarkerPoint.y, endMarkerPoint.y) - markerHeight,
Math.max(startMarkerPoint.x, endMarkerPoint.x) + markerWidth,
Math.max(startMarkerPoint.y, endMarkerPoint.y) + markerHeight
);
if(maxMarkerBounds.x < 0 || maxMarkerBounds.y < 0 ||
maxMarkerBounds.width > map.width || maxMarkerBounds.height >
map.height)
{
map.setZoom(map.getZoom() - 1);
}
It basically checks, if one of the markers position is out of the maps
bounds. If so, set zoom level -1.
On Oct 15, 6:10 pm, Aron <[email protected]> wrote:
> var bounds : LatLngBounds = directions.bounds;
> bounds.extend(someMarker.getLatLng());
> //some more extend() here
> map.setZoom(map.getBoundsZoomLevel(bounds));
>
> works as expected. However, it does (of course) not include the visual
> size of the marker. Which loads to the following (in some cases):
>
> http://twitpic.com/2xswpy
>
> It gets even worse, when I'm using my custom marker icons, which are
> even bigger then the default marker.
>
> So I'm looking for a way to include the (pixel) size of the markers in
> the calculation.
>
> An alternative would be to set a padding (in pixel) around the bounds,
> to ensure, that the marker are always fully visible.
>
> Thanks in advance
--
You received this message because you are subscribed to the Google Groups
"Google Maps API For Flash" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api-for-flash?hl=en.