3

Hi I am going to include a google maps to my web application and I will use markers. The map works perfectly, the problem is that I don't want people to be able to do maximum zoom for security reasons. I need to put a limit on the zoom, and I can´t find out how. I don´t know how to do it in javascript, can anybody help?

This is the script I use:

<script type="text/javascript">
 var locations = [    
  ['<b>Location:</b> England<br /><br /><b>Product:</b> ISIS Professional (1D)<br /><br /><b>Managing tidal flood risk</b>', 51.5171, 0.1062, 1] ];

var map = new google.maps.Map(document.getElementById('map'), {


      center: new google.maps.LatLng(47.754097979680026, 15.1171875),
      zoom: 2,
      mapTypeControl: true,
      draggable: true,
      scaleControl: false,
      scrollwheel: false,
      zoomControl: true,
      navigationControl: false,
      streetViewControl: true,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var image = 'img/pointer.png';
    var infowindow = new google.maps.InfoWindow();
    var marker, i;
    for (i = 0; i < locations.length; i++) {  
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        map: map,
        icon: image 
      });
      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
        }
      })(marker, i));
    }
  </script>
tiago
  • 22,602
  • 12
  • 72
  • 88
user2331670
  • 335
  • 2
  • 6
  • 15

1 Answers1

13

You can do it by fixing minZoom and maxZoom for your map.

Check out

 var opt = { minZoom: 6, maxZoom: 9 };
 map.setOptions(opt);

EDIT

Check This Link for more info.

gprathour
  • 14,813
  • 5
  • 66
  • 90