map repeat for small zoom size

1,826 views
Skip to first unread message

Yauhen

unread,
Sep 21, 2011, 7:45:23 AM9/21/11
to google-map...@googlegroups.com

Is there any way to disable map repeat for small zoom levels.


For example for standard map from sample just move zoomer to lowest position and map will have duplicates.
The most problem is that duplicates will contain duplicate markers etc which could confuse user.

The only solution I have found is to set max zoom level to some value. But this is type of hack. I am also not sure may be such solution will have problems if map size will change (if user have other screen resolution then my or change window size).

Any other ideas?

JKurtock

unread,
Sep 21, 2011, 5:22:18 PM9/21/11
to Google Maps JavaScript API v3
Can you describe what you mean by "map repeat"? When I zoom the
samples you cite, everything looks fine all the way to maximum zoom.

- Jeff

On Sep 21, 4:45 am, Yauhen <yauhe...@gmail.com> wrote:
> Is there any way to disable map repeat for small zoom levels.http://code.google.com/intl/en-Us/apis/maps/documentation/j<http://code.google.com/intl/en-Us/apis/maps/documentation/javascript/...>
> avascript/examples/map-simple.html<http://code.google.com/intl/en-Us/apis/maps/documentation/javascript/...>

Yauhen

unread,
Sep 22, 2011, 3:37:58 AM9/22/11
to Google Maps JavaScript API v3
I mean not maximum but minimum (sometimes in email I said this).
Here is screenshot just whole world shown several times
http://i52.tinypic.com/2euhk7k.png
At least it will be good to not show markers several times. But the
best will be of course to not duplicate.
Message has been deleted

Yauhen

unread,
Sep 23, 2011, 9:04:28 AM9/23/11
to Google Maps JavaScript API v3
If anybody have some ideas I yould like to test them.
On current moment I have stopped on minZoom: 1 solution:

new google.maps.Map(canvas, {
center: mapCenter,
minZoom: 1,
mapTypeId: google.maps.MapTypeId.ROADMAP
};);

min could vary based on map pixels size. I haven't found any other
good way to fix this.

On 22 сен, 10:37, Yauhen <yauhe...@gmail.com> wrote:
> I mean not maximum but minimum (sometimes in email I said this).
> Here is screenshot just whole world shown several timeshttp://i52.tinypic.com/2euhk7k.png
> At least it will be good to not show markers several times. But the
> best will be of course to not duplicate.
>
> On 22 ÓÅÎ, 00:22, JKurtock <jkurt...@gmail.com> wrote:
>
>
>
> > Can you describe what šyou mean by "map repeat"? When I zoom the
> > samples you cite, everything looks fine all the way to maximum zoom.
>
> > - Jeff
>

xelawho

unread,
Sep 23, 2011, 11:34:34 AM9/23/11
to Google Maps JavaScript API v3
> min could vary based on map pixels size. I haven't found any other
> good way to fix this.

I suspect min zoom may be the way to go... have you tested on other
devices, screen resolutions to make sure it doesn't suit your purpose?

what you *could* do is set a listener that looks out for when the user
is zooming out and the bounds longitude changes from neg to pos (or
vice versa) - which by my muddled way of thinking is the only way to
tell if the map has started wrapping:

var zoom;

google.maps.event.addListener(map, 'bounds_changed', function() {
if
((map.getZoom()<zoom)&&((map.getBounds().getNorthEast().lng()>0&&neLng<0)||
(map.getBounds().getSouthWest().lng()<0&&swLng>0))){
alert("too many maps!");
}
swLng=map.getBounds().getSouthWest().lng();
neLng=map.getBounds().getNorthEast().lng();
zoom=map.getZoom();
});

but what you actually do with the "too many maps!" scenario is the
next question that you would have to answer...

Yauhen

unread,
Sep 23, 2011, 12:06:51 PM9/23/11
to Google Maps JavaScript API v3
1) Map occupy remaining space from page excluding footer, header, list
of search results to the left of map (like http://maps.google.ca/)).
All except map have fixed size. Map should be not fixed.
For my 1280*1024 it shows with minZoom:1 whole world with just some
part of asia.
I have changed it to 1024*768 abnd it become showing less part of the
asia. So I suspect that for small screens it could be problems that
min zoom will not show whole world. As for cases with large dimensions
solution will not fix anyway problem (not 3 times duplicate like on
link but 1.7).
2) for your solution.
a. How I could cancel zoom in case of alert?
b. Does this checks guarantees that user could see full map? Because
height could become negative quicker then width in this case user will
not able to see full world. (but of course duplicate problem not
appears)

xelawho

unread,
Sep 23, 2011, 12:19:30 PM9/23/11
to Google Maps JavaScript API v3
> 2) for your solution.
> a. How I could cancel zoom in case of alert?

ha. yes. that is the question. at the very least you could substitute
the alert for:
map.setZoom(zoom);

but I don't know that we haven't just reinvented a more roundabout way
of setting min zoom.

> b. Does this checks guarantees that user could see full map? Because
> height could become negative quicker then width in this case user will
> not able to see full world. (but of course duplicate problem not
> appears)

yes (as far as I can tell) - the listener only listens for changes in
the longitude, if the eastern or western bounds go from positive to
negative. It completely ignores what's going on with north and south.
Although it probably needs more testing and conditions added for if
the reverse happens with the longitudes (depending on where your map
is going to be centered in the first place)
Reply all
Reply to author
Forward
0 new messages