When I try to display a map wiith AJAX Command (depending of choices on a form), it only renders a div like that :
<div id="leaflet-map--OwQZAsqWLCo" style="min-width: 150px; height: 400px"></div>
The same code displaying in a block, is working.
What can I do ?
My code :
/**
* Get the map from ws.
*/
public function getMapWs($items)
{
// define map features from lat/lng
$features = [];
foreach ($items as $delta => $item) {
// define map features from lat/lng
$features[] =
[
'type' => 'point',
'lat' => $items[$delta]['latitude'],
'lon' => $items[$delta]['longitude'],
'popup' => Markup::create($items[$delta]['nom']),
];
}
$map_service = \Drupal::service('leaflet.service');
// set map type (default leaflet OSM)
$settings['leaflet_map'] = 'OSM Mapnik';
// set $map array with leafletMapGetInfo
$map_info = $map_service->leafletMapGetInfo($settings['leaflet_map']);
$map_info['settings']['map_position_force'] = 0;
$map_info['settings']['zoom'] = 12;
$map_info['settings']['zoomFiner'] = 0;
$map_info['settings']['minZoom'] = 1;
$map_info['settings']['maxZoom'] = 18;
$map_info['settings']['center'] = ['lat' => 0, 'lon' => 0];
$map_info['settings']['fullscreen_control'] = 0;
$map_info['settings']['maxZoom'] = 18;
$map = $map_service->leafletRenderMap($map_info, $features, '400px');
return render($map);
}
Active
2.1
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.