Визиком карты

Events

This example shows the processing of events click on the map, dragging the map and marker.


For maps there are events changing scale and beforezoomchange onzoomchange.
The first is called immediately before the change and allows it to block.
This function should return false
In this example blocks all scales up to 5th.

Display in browser:

Description of events:

Source code:

var marker = new VMarker(point);
marker.draggable(true);
map.add(marker).repaint();
map.mouseclick(
function(coords) {
    addMessage("Click on the map: " + coords.lng.toPrecision(6) +
        ", " + coords.lat.toPrecision(6) +
        " (map.mouseclick)");
    }
);
marker.enddrag(
function() {
    addMessage("You pulled a marker (marker.enddrag)");
    }
);
map.enddrag(
function() {
    addMessage("You pulled the map (map.enddrag)");
    }
);
map.beforezoomchange(
function(newIndex) {
    if (newIndex < 6) {
        addMessage("Lock change scale (map.beforezoomchange)");
        return false;
    }
    addMessage("Change of scale in " + newIndex +
        " (map.beforezoomchange)");
    }
);
map.onzoomchange(
function() {
    addMessage("Map scale changed (map.onzoomchange)");
    }
);