Custom parameters example

Now that we know how to center the map to a selected position, we would like to change some default features or visualizations of the map. We can override the default behaviour of the map properties via the defaults attribute. The options are pretty self-explanatory:

{ maxZoom: 14, minZoom: 1, doubleClickZoom: true, scrollWheelZoom: true, attributionControl: true, tileLayer: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', tileLayerOptions: { attribution: '© OpenStreetMap contributors' }, icon: { url: 'http://cdn.leafletjs.com/leaflet-0.6.4/images/marker-icon.png', retinaUrl: 'http://cdn.leafletjs.com/leaflet-0.6.4/images/marker-icon@2x.png', size: [25, 41], anchor: [12, 40], popup: [0, -40], shadow: { url: 'http://cdn.leafletjs.com/leaflet-0.6.4/images/marker-shadow.png', retinaUrl: 'http://cdn.leafletjs.com/leaflet-0.6.4/images/marker-shadow.png', size: [41, 41], anchor: [12, 40] } }, path: { weight: 10, opacity: 1, color: '#0000ff' }, center: { lat: 0, lng: 0, zoom: 10 } }

We can override the properties we would like to change, for example, to obtain a map like the upper one you see on this page. Let's see the necessary code:

You can see a standalone example of this code here.