I'm trying to change the zoom levels for both maxZoom and minZoom.

I'm able to hard code the changes in openlayers_layer_type_google.js, and works for the most part and does what I want.

But I don't want to do it this way. I want the values to be entered in the drupal admin 'layers' edit pg [admin/structure/openlayers/layers/list/google_normal/edit]

The new form element I added show up and work fine.

However, when I load the map, I get the error msg:

Error: Invalid value for property : 016

Here's the code I added to 'function options_form($defaults = array())' in openlayers_layer_type_google.inc :

//max zoom levels
 'maxZoomLevel' => array(
   '#type' => 'textfield',
   '#title' => t('Maximum Zoom Level'),
   '#description' => t('Set the maximum zoom level'),
   '#default_value' => isset($this->data['maxZoomLevel']) ?
   $this->data['maxZoomLevel'] : '30'
 //min zoom levels
 'minZoomLevel' => array(
   '#type' => 'textfield',
   '#title' => t('Minimum Zoom Level'),
   '#description' => t('Set the minimum zoom level. Will restrict users from zooming out.'),
   '#default_value' => isset($this->data['minZoomLevel']) ?
   $this->data['minZoomLevel'] : '16'


wluisi’s picture

To further clarify if it's unclear. My map works fine when I directly modify the openlayers_layer_type_google.js code w/ this:

Drupal.openlayers.layer.google = function(title, map, options) {
var styleMap = Drupal.openlayers.getStyleMap(map, options.drupalID);

// if G_ vars exists we're using gmap v2
var google_type_map = {
'normal': window['G_NORMAL_MAP'] || null,
'satellite': window['G_SATELLITE_MAP'] || google.maps.MapTypeId.SATELLITE,
'hybrid': window['G_HYBRID_MAP'] || google.maps.MapTypeId.HYBRID,
'physical': window['G_PHYSICAL_MAP'] || google.maps.MapTypeId.TERRAIN

options.sphericalMercator = true;
options.maxExtent = new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34);
options.type = google_type_map[options.type];
options.projection = "EPSG:900913";

//Added options
options.maxZoomLevel = 30;
options.minZoomLevel = 16;

var layer = new OpenLayers.Layer.Google(title, options);
layer.styleMap = styleMap;

return layer;