When I print out the map rendered by the code below the map div is all grey and I get the error message:
Uncaught TypeError: Cannot read property 'layerControl' of undefined
$leaflet_map = leaflet_leaflet_map_info();
$leaflet_features = array(
array(
'type' => 'point',
'lat' => $vars['node']->field_geo['und'][0]['lat'],
'lon' => $vars['node']->field_geo['und'][0]['lon'],
'icon' => array(
'iconUrl' => '/sites/default/themes/mytheme/img/map-marker.png'
),
'popup' => l($vars['node']->title, 'node/' . $vars['node']->nid),
'leaflet_id' => 'company' . $vars['node']->nid
)
);
$vars['company_map'] = leaflet_render_map($leaflet_map, $leaflet_features, '300px');
See attached screenshots for additional info.
| Comment | File | Size | Author |
|---|---|---|---|
| leaflet-typeerror-console.png | 23.48 KB | persand | |
| leaflet-typeerror.png | 8.3 KB | persand |
Comments
Comment #1
rogical commentedsame issue
Comment #2
rdeboerI think the problem with the code in this issue is that it does not treat the return value of
leaflet_map_get_info()as an array.So in the call to
leaflet_render_map()you probably want to pass inreset($leaflet_map), rather than$leaflet_mapSee this code taken from the Leaflet Demo module (submodule of Leaflet More Maps).
This code renders the same set of features on ALL of the maps returned from
leaflet_map_get_info(). You can see the result here: http://flink.com.au/tips-tricks/27-reasons-not-to-use-google-mapsComment #3
rdeboer