Simple API Help

This page describes how to use the Simple API. The Simple API provides a JavaScript API for inserting simple maps into web pages.

Basis

To use the API you should add the following HTML:


<link href="https://mapnv.ch/api.css" rel="stylesheet">
<script src="https://mapnv.ch/api.js?version=2"></script>
<script>
window.onload = function() {
    // add the code here
};
</script>
            

To put a new map in the page you'll have to put a div element with a certain id where you want your map to be:

<div id='map1' style='width:700px;height:400px;'></div>

Search input

var map = new mapnv.Map({
    div: 'map10',
    zoom: 3,
    center: [2538181, 1183651],
    searchDiv: 'map10search'
});
                    

A map

var map = new mapnv.Map({
    div: 'map1', // id of the div element to put the map in
    zoom: 4,
    center: [2538181, 1183651]
});
                    

A map with a marker on its center

var map = new mapnv.Map({
    div: 'map2',
    zoom: 8,
    backgroundLayers: ['Plan-couleur'],
    center: [2538181, 1183651]
});
map.addMarker();
                    

A map with a subset of overlays

var map = new mapnv.Map({
    div: 'map4',
    zoom: 0,
    center: [2538707, 1181061],
    layers: ['POI_admin_y_no_maxscaledenom']
});
                    

A map with some additional controls

var map = new mapnv.Map({
    div: 'map5',
    zoom: 3,
    center: [2538181, 1183651],
    layers: ['POI_admin_y_no_maxscaledenom'],
    addLayerSwitcher: true,
    addMiniMap: true,
    miniMapExpanded: true,
    showCoords: true
});