Configuration

The extension is configured in the JMap Admin project configuration page:

  1. Open the NG Configuration tab.

  2. Drop the javascript code that will be executed when opening, then save.

  3. Once the javascript code is saved, activate the extension in the Extensions section of a project configuration page. Make sure the code is functional before activating the extension, otherwise errors may occur when opening JMap NG for current users of the project.

Configuration examples

The following code adds an Atari logo and a base map from Geogratis. It also zooms to coordinates 45.630701447925134, -73.54322795543986 :

JMap.Map.Attribution.addMultiple([{
    id: "custom-attribution-0",
    text: "? K2Geospatial",
    imageUrl: "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Atari_logo.svg/640px-Atari_logo.svg.png",
    href: "https://k2geospatial.com/jmap-en/"
}, {
    id: "custom-attribution-1",
    text: "? StackOverflow",
    href: "https://stackoverflow.com/"
}]);
JMap.Map.Basemap.removeById("canvec");
JMap.Map.Basemap.add({
    id: "canvec",
    label: "Geogratis-test",
    tileUrls: [
        "https://maps.geogratis.gc.ca/wms/canvec_en?&version=1.3.0&REQUEST=GetMap&format=image/png&transparent=true&width=512&height=512&crs=EPSG:3857&bbox={bbox-epsg-3857}&layers=land,hydro,man_made,residentialarea_50k,transport,administrative"
    ]
}, true);
JMap.Map.panAndZoomTo({
    "x": -73.54322795543986,
    "y": 45.630701447925134
}, 10);

Example configuration to change the value of JMAP_OPTIONS.reportsBaseUrl based on a given URL.

if (window.location.href.includes("myjmap.com"))  {
      JMAP_OPTIONS.reportsBaseUrl = "http:/reports.myjmap.com/diffuser/2.0/";
      console.log('NG Configuration: Reports home changed to ' + JMAP_OPTIONS.reportsBaseUrl);
}

Dernière mise à jour

K2 Geospatial 2024