Forum Moderators: open

Message Too Old, No Replies

google maps limit zone

         

helenp

4:41 pm on Feb 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi I am going to include a google maps to my web with markers,
the map works perfect, the problem is that I donīt want people to be able to do max zoom for security reason, so I need to put an limit zoom in it, and I canīt find out how to on internet, I donīt know javascript to do it for myself, can anybody help?

This is the script I use:


function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}

// Display the map, with some controls and set the initial location
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(36.51308543049258, -4.886341094970703), 13);

// Set up markers with info windows

var point = new GLatLng(36.51122284207668,-4.888572692871094);
var marker = createMarker(point,'<div style="width:240px">Information text here</div>')
map.addOverlay(marker);

Thanks in advance

lammert

12:50 am on Feb 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



the problem is that I donīt want people to be able to do max zoom for security reason,

If this is for security reasons, why then mention the coordinates in your post? In general blocking zooming in your application won't block zooming in maps.google.com if people just cut and past the coordinates.

phranque

8:19 am on Feb 11, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



this is admittedly "paraphrased" code but i don't think the original author would mind not being cited here:

// set min/max map scale
var minMapScale = 5;
var maxMapScale = 10;
// get array of map types
var mapTypes = map.getMapTypes();
// overwrite the getMinimumResolution() and getMaximumResolution() methods for each map type
for (var i=0; i<mapTypes.length; i++) {
mapTypes[i].getMinimumResolution = function() {return minMapScale;}
mapTypes[i].getMaximumResolution = function() {return maxMapScale;}
}

helenp

11:32 am on Feb 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks, that works just perfect.
Thanks again.