Documentation

Set Map Zoom

The default zoom level of a Micello map is based on the size of the map container when the map is loaded. The zoom will be set so the whole community appears within the map container.

This example shows how to change the zoom level as soon as the map loads:

micello.maps.init (apikey, mapInit);
var mapControl;
function  mapInit() {
    mapControl = new micello.maps.MapControl('mapElement');
    var mapDataObject = mapControl.getMapData();
    mapDataObject.mapChanged = onMapChanged;
    mapDataObject.loadCommunity(15);
}
 
function onMapChanged (e) {
    if (e.comLoad) {
        var mapView = mapControl.getMapView();
//        var currentZoom = mapView.getZoom(); // to get the current zoom level
        mapView.setZoom(2.8);
    }
}

This example uses a mapChanged override to detect that the map has fully loaded before attempting to change the zoom level. A different example covers the use of the mapChanged Override.

The method getZoom() (line 13) can be used to get the current zoom level of a map which can be used to generate a new zoom level or simply logged for debugging.

The same methods used above in onMapChanged() can be used to change the zoom level in response to an event.