Closed arverne63 closed 4 years ago
Files project leaflet-elevation_gpx-waypoints.txt leaflet-ui-src.txt
Basically you just need to extend default map options:
var opts = {
maps: {
// Common leaflet options
center: [45.128074, 3.997882],
zoom: 10,
// Custom leaflet-ui options
mapTypeId: 'ign',
mapTypeIds: ["streets", "terrain", "satellite", "topo", "ign"],
mapTypes: {
ign: { // <-- DEFINE A NEW MAPTYPE ID
name: "IGN",
url: 'https://wxs.ign.fr/{apiKey}/geoportail/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer={layer}&format=image/jpeg&style=normal',
options: {
apiKey: 'IGN_KEY', // <-- CHANGE IT WITH YOUR IGN API KEY
layer: 'GEOGRAPHICALGRIDSYSTEMS.MAPS',
minZoom: 0,
maxZoom: 24,
maxNativeZoom: 18,
tileSize: 256,
attribution: "IGN-F/Géoportail"
},
}
},
...
}
};
// Set leaflet map options
var map = new L.Map('maps', opts.maps );
Alternatively you can just ovveride one of the predefined map types:
var opts = {
maps: {
...
mapTypeId: 'topo',
mapTypeIds: ["streets", "terrain", "satellite", "topo"],
mapTypes: {
topo: { // <-- OVERRIDE A DEFAULT MAPTYPE ID
name: "IGN",
url: 'https://wxs.ign.fr/{apiKey}/geoportail/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer={layer}&format=image/jpeg&style=normal',
options: {
apiKey: 'IGN_KEY', // <-- CHANGE IT WITH YOUR IGN API KEY
layer: 'GEOGRAPHICALGRIDSYSTEMS.MAPS',
minZoom: 0,
maxZoom: 24,
maxNativeZoom: 18,
tileSize: 256,
attribution: "IGN-F/Géoportail"
},
}
},
...
}
};
Regards, Raruto
Good morning, It is working very well now. Thank you. Jean Marc
Good evening, I created a web page following your leaflet-elevation project with the gpx waypoint icon example. I would like to add an ign map background, for this I have modified the file leaflet-ui-src.js as below after the code of the Topo map (lines 3879 a 3890)
And also add the label "ign" in the mapTypeIds, (line 3977)
but it doesn’t work. Thank you in advance for your help.
Jean Marc.