Working with the mapChanged event is essential to developing with Micello maps. Because our maps load asynchronously, many methods of the API require the map to be fully loaded to function correctly. Fortunately, the mapChanged event fires every time a map level or drawing is changed, as well as when the map loads.

Here is what map initialization looks like with the mapChanged event overridden:

micello.maps.init (apikey, mapInit);
function  mapInit() {
    var mapControl =  new micello.maps.MapControl('mapElement');
    var mapDataObject = mapControl.getMapData();
    mapDataObject.mapChanged = onMapChanged; // specify an override

The custom override function would look like this:

function onMapChanged (e) {
    if (e.comLoad) { // true the first time the map loads
        // execute code here, the map is fully loaded

The event object will have this structure: {"comLoad":1,"drawChange":0,"drawLoad":0}

Notice that there is no indication for levelChange, but the event is still triggered with all the other properties set to 0.

Refresh the map, or change levels and drawings to see the event object passed through the mapChanged method.