let url = origin/map42/?
let p = Object.fromEntries(new URL(location).searchParams.entries()); // pares the url parameters
//let p = params / key: value json object.
p.mapinfo = [zoom, center_lat, center_lng] // set the basic map zoom and position.
p.basefilter=index_of_filter // apply css filter to base map layer
p.server=wms_server_url_to_load_overlayers_of // wms server to get overlay layers from
p.rox=[url, p1, p2, p3, opacity] // image overlays to render on the client note this is base of prefix ro so x can be anything.
p.urlayers=[urlayer_spec1, urlayer_spec2, ...] // json overlays to render on the client
p.measure=[[lat1, lon1], [lat2,lon2], ...] //a measurement in the measure tool to display
p.h3viewer=[h3cell1, h3cell1, ...] // enable h4 hex cell viewer and saved layer. note buggy
p.gps=1 // draw a marker on you gps location.
todo document urls for all finalized mode .
sorry alpha customers your on your own reach out with questions!
[email protected]
Normally this gets handled in the decode stage but in upload make sure to use getParam_______()
whitch probably does it right.
Embeding Freemap in an ifream on your site: Note you may want to adjust the site. You can use this site to preview and genreate your iframes. https://html-css-js.com/html/generator/iframe/
If you insist on implementing this yourself il use the mapinfo as an example.
function getParamMapinfo() {
let z = map.getZoom()
let c = map.getCenter()
let a = [z, c.lat, c.lng] ; // as you can see here we make an array before
return "mapinfo=" + encodeURIComponent(JSON.stringify(a))
// then we stringify the array and finally encode it for safe usage in urls.
}
/**
*
* @param a [zoom, lat, lng]
* @return {zoom, latlng: {lat, lng}}
*/
function mapinfoToZoomLatLng(a) {
return {
zoom: a[0],
latlng: L.latLng(a[1], a[2])
}
}
function setMapinfo(params) {
try {
let a = JSON.parse(p.mapinfo); // and so finally here we get string already decoded and simply need to parse the json
if (!Array.isArray(a) || a.length !== 3) {
console.log("No param or invalid json")
}
// let {zoom, latlng} = mapinfoToZoomLatLng(a);
let zoom = a.shift();
map.panTo(L.latLng(a))
map.setZoom(zoom)
} catch (e) {
// note error catching invalid encoded json
console.error("Invaled mapinfo doing nothing [zoom, lat, lon]")
}
}
// we asume this line has ran elsewhere.
// let p = Object.fromEntries(new URL(location).searchParams.entries());
if (p && p.mapinfo) {
setMapinfo(p) ; // in the loading step we assume we have already decodes our params as the URLSearchParams object does that.
}