Hi @ruenel,
thanks for following this up. There indeed seems to be a conflict, and although I’m quite experienced in debugging JS, this one is above my head. So I’m thankful the team wants to investigate this further!
As stated, it’s Javascript that runs as an ES-module so it’s included through functions.php:
add_action('wp_enqueue_scripts', 'dev_enqueue_topotrainer');
function dev_enqueue_topotrainer() {
wp_enqueue_script('dev-topotrainer-es-js', get_template_directory_uri().'-child/topotrainer-es-debug.js', array( 'jquery' ), '0.0.1',array('strategy' => 'defer', 'in_footer'=>true));
}
/**
*Script that import modules must use a script tag with type="module",
* so let's set it for the script.
*/
add_filter( 'script_loader_tag', function ( $tag, $handle, $src ) {
if($handle == 'dev-topotrainer-es-js') {
$tag = '<script type="module" src="' . esc_url( $src ) . '"></script>';
};
return $tag;
}, 10, 3 );
The ‘dev-topotrainer-es-js.js’ file:
import esriConfig from "https://js.arcgis.com/4.27/@arcgis/core/config.js";
import Map from "https://js.arcgis.com/4.27/@arcgis/core/Map.js";
import MapView from 'https://js.arcgis.com/4.27/@arcgis/core/views/MapView.js';
import TileLayer from "https://js.arcgis.com/4.27/@arcgis/core/layers/TileLayer.js";
import FeatureLayer from "https://js.arcgis.com/4.27/@arcgis/core/layers/FeatureLayer.js";
import Expand from "https://js.arcgis.com/4.27/@arcgis/core/widgets/Expand.js";
import Legend from "https://js.arcgis.com/4.27/@arcgis/core/widgets/Legend.js";
/*
* Configuration
*/
const nameSpace = 'tpgrf';
esriConfig.apiKey = "SEE THE SECURE NOTE";
const basemapLayer = new TileLayer({
url:"https://tiles.arcgis.com/tiles/nSZVuSZjHpEZZbRo/arcgis/rest/services/Topografie_in_de_klas_nederland_ondergrond/MapServer"
});
const contentLayer = new FeatureLayer({
url: "https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/FeatureServer/0"
});
const highlightLayer = new FeatureLayer({
url: "https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/FeatureServer/1"
});
/*
* Build map and view
*/
const map = new Map({
basemap: "arcgis-topographic", // Basemap
});
const view = new MapView({
map: map,
container: "viewDiv", // Div element
});
I’m very curious where you find the ArcGIS Javascript API imported as an ES-module is interfering with Pro/Cornerstone. Any insights would be much appreciated; I’m trying to convert a very successful non-profit website into a cornerstone-drive website, but that will only work if I can use the ArcGIS Javascript API 