That's fantastic thanks! Worked like a charm (although I had to add
another closing bracket to each of the statements!)

Massively grateful for your detailed response and help - it's relieved
my headache! Thanks again!

Matt

On Feb 13, 10:53 am, Andrew Leach <[email protected]> wrote:
> On 13 February 2012 09:58, Matt <[email protected]> wrote:
>
>
>
> > The problem is that if you 
> > usehttp://www.mammothmattress.com/find_nearest.html
> > and the postcode NE1 1NE in a 10 or 25 mile radius, the two nearby
> > points are right on the edge of the page. Is there a way to set a
> > limit of how near the edge of the map they are before it zooms out? Or
> > simply to set the zoom level to the bounds, minus one level of zoom?
>
> > I imagine it's an edit to
>
> > map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
>
> Currently you set "bounds" with
>    bounds.extend(point);
> and it's that line which needs to be altered, so that a different
> "bounds" is used to set the zoom level.
>
> The way to cater for markers near the edge is to extend a bounds
> object by each marker's position **plus a margin**. The margin won't
> make any difference if the markers are far enough away from the edge.
>
> For ordinary-shaped markers, you can adjust the margin so it's not
> much more than zero at the south edge but a bit more at the north edge
> so the marker will be shown if it's near the top of the map.
>
> So, replace this line
>   bounds.extend(point);
> with something like
>   // buffer zone above marker point
>   bounds.extend(new GLatLng(point.lat()+.005,point.lng());
>   // buffer zone below marker point
>   bounds.extend(new GLatLng(point.lat()-.00005,point.lng());
>   // buffer zone left of marker point
>   bounds.extend(new GLatLng(point.lat(),point.lng()-0.0005);
>   // buffer zone right of marker point
>   bounds.extend(new GLatLng(point.lat(),point.lng()+0.0005);
>
> You don't the original bounds.extend(point) because that point is
> contained within the four you create and add afterwards. You may need
> to play with the figures for best results. Because the actual
> on-screen distance varies with zoom level (0.005 at zoom 23 is
> millions of times further on-screen than 0.005 at zoom 3) there will
> have to be a level of compromise.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API V2" 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?hl=en.

Reply via email to