Hi,
I try to use the module but my below example doesn't show map. Hereby my screenshot. There is an issue in JS but don't find it...
Someone can help me ?

    $map = leaflet_leaflet_map_info();
    $features = array(
        array(
            'type' => 'point',
            'lat' => 44,
            'lon' => 6.45,
            'icon' => array(//'iconUrl' => 'sites/default/files/mymarker.png'
            ),
            'popup' => $title,
            'leaflet_id' => 'someID'
        ),
    );
    print leaflet_render_map($map, $features, "100px");

Firebug error :

TypeError: this.map.settings is undefined
[Stopper sur une erreur] 	

if (this.map.settings.layerControl) {
CommentFileSizeAuthor
Screen Shot 2013-05-23 at 3.05.09 PM.png58.89 KBjim005

Comments

chrsnlsn’s picture

Same for me, just a grey map with zoom controls. Anyone confirm that the API is working for them?

timdavison’s picture

I think you need to set up the $map variable with a call to leaflet_get_map_info(). I've used the code below in a block to test the api and it all works fine for me. (OSM Mapnik is the default map set up by the leaflet module).

<?php

    // Get default map implementation
    $map = leaflet_map_get_info('OSM Mapnik');
    // Set initial zoom level.
    $map['settings']['zoom'] = 8;
    
    // Create settings for the map.
    $features = array(
      array(
        'type' => 'point',
        'lon' =>-0.3161,
        'lat' => 52.5493,
      ),
    );

    print leaflet_render_map($map, $features, "250px");
?>
jim005’s picture

Great ! It works ! ... So easy now, I can switch to leaflet easily :-)

rdeboer’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

vistree’s picture

Issue summary: View changes

Hi, where to use the api if you want to manipulate an existing views leaflet map?
I want to change some of the feature settings or set a new layer by code.

Tried several leaflet-functions .. Or do you need to use a jquery-script?

szeidler’s picture

@vistree: there is a hook_leaflet_map_info_alter that can be used to manipulate the configuration of any existing map.