I created a view to display the node geo location (via an address field) on map. It display correctly but by default the map is zoom to the maximum level 18. I want to set the default zoom level to 14 on page load but also allow users to zoom in and out.

I used hook_leaflet_map_info() to create a custom map output. The "maxZoom" setting works but the "zoom" setting does not. I set "zoom" to 14, and "maxZoom" to 18 but the default zoom level at page load is still 18. If i set "maxZoom" to 14, the default level is 14 but the user will not be able to zoom in any further.

I've also tried to change these value in leaflet.module but it didnt work either

Much appreciate if anyone can point me to the right direction to fix this issue.

Here is my hook:


<?php
function leaflet_tweaks_leaflet_map_info() {
  return array(
    'custom map' =>
    array(
      'label' => 'custom map',
      'description' => t('Leaflet map with custom zoom settings.'),
      'settings' => array(
        'dragging' => TRUE,
        'touchZoom' => TRUE,
        'scrollWheelZoom' => TRUE,
        'doubleClickZoom' => TRUE,
        'zoomControl' => TRUE,
        'attributionControl' => TRUE,
        'trackResize' => TRUE,
        'fadeAnimation' => TRUE,
        'zoomAnimation' => TRUE,
        'closePopupOnClick' => TRUE,
        'layerControl' => TRUE,
	    'maxZoom' => 18,
	    'zoom' => 14,
      ),
      'layers' => array(
        'earth' => array(
          'urlTemplate' => 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
          'options' => array(
            'attribution' => 'custom map'
          )
        ),
      ),
    ),
  );
}
?>

Thanks,
Billy

Comments

pvhee’s picture

Status: Active » Fixed

This is now fixed, please use the latest dev release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mabf’s picture

Title: Default zoom level in leaflet_map_info() does not work on views map » To change leaflet by defect
Version: 7.x-1.0-beta1 » 7.x-1.x-dev

I am using Leaflet in Drupal 7,18 and to change the direction to me that comes by defect (514777 length -0,0015 Latitude and 14 zoom lens “GreenwichPark”)
Since I can do it?