Set Map Drawing

Some Micello maps are large enough they're organized into separate drawings. These drawings can be changed programatically by the developer in response to user events. The method setDrawing() accepts a drawing object as an argument and refreshes the map to show that drawing. If the map needs to load to a drawing other than the default, see the example Set Map.

This code will use a click event to trigger the drawing change.

micello.maps.init (apikey, mapInit);
function  mapInit() {
    var mapControl =  new micello.maps.MapControl('mapElement');
    var mapDataObject = mapControl.getMapData();
    mapDataObject.mapChanged = onMapChanged;
document.getElementById("change_drawing").onclick = function () {
    var comm = mapDataObject.getCommunity();

The important lines of this example are lines 10 and 11. On line 10, the method getCommunity is used to assign the community object to the variable comm. The drawings within a community are stored in the property 'd', where comm.d[0] represents the default drawing. Line 11 shows the use of setDrawing(), which accepts a drawing object as a sole argument.

An optional 2nd argument, levelId, can be passed to setDrawing() to load a specific level of a drawing:

mapDataObject.setDrawing(drawingObject, levelId);

Change a new drawing index and click 'Change Drawing' to see the map load to a different drawing. (Hint: 0, 1 & 2 will work! There are 3 drawings, including the default.)