Hi @hupe13,
I expect that when another Map variant is used, elevation
for example, it results in an additional JavaScript file/dependency being loaded, which will also have to be blocked in the integration file.
Otherwise the elevation
script would be loaded while the others are still blocked, resulting in a failure for the Map to initialize correctly. I see that the current ‘leaflet’ integration doesn’t correctly block all of those scripts and dependencies.
Could you try replacing the Leaflet integration with the below version? I haven’t verified it myself yet, but this version also blocks the Leaflet Extensions and tells them to wait for the “main” Leaflet script to load.
<?php
defined( 'ABSPATH' ) or die( "you do not have access to this page!" );
add_filter( 'cmplz_known_script_tags', 'cmplz_leafletmaps_directory_script' );
function cmplz_leafletmaps_directory_script( $tags ) {
$tags[] = array(
'name' => 'openstreetmaps',
'category' => 'marketing',
'placeholder' => 'openstreetmaps',
'urls' => array(
'WPLeafletMapPlugin',
'leaflet-gesture-handling',
'extensions-leaflet-map',
),
'enable_placeholder' => '1',
'placeholder_class' => 'leaflet-map',
'enable_dependency' => '1',
'dependency' => [
//'wait-for-this-script' => 'script-that-should-wait'
'WPLeafletMapPlugin' => 'leaflet-gesture-handling',
'WPLeafletMapPlugin' => 'extensions-leaflet-map',
],
);
return $tags;
}
/**
* Add services to the list of detected items, so it will get set as default, and will be added to the notice about it
*
* @param $services
*
* @return array
*/
function cmplz_leafletmaps_directory_detected_services( $services ) {
if ( ! in_array( 'openstreetmaps', $services ) ) {
$services[] = 'openstreetmaps';
}
return $services;
}
add_filter( 'cmplz_detected_services', 'cmplz_leafletmaps_directory_detected_services' );
Let me know if that does the trick!
Kind regards, Jarno