Skip to content
tmcw edited this page Jan 18, 2012 · 1 revision

Modest Maps assumes you want an interactive map for use in a desktop web browser and automatically creates a MM.MouseHandler and MM.TouchHandler for dealing with mouse drag, double click and wheel events.

If you create a map with an empty array in the fourth parameter it is then up to you to write the interaction code and use functions like map.panBy and map.zoomBy to move the map in response to events:

// fourth argument is null, map will be static (no mouse actions):
var map = new MM.Map(parent, provider, dimensions, null);

Event handlers are currently properties of the map (hence they are passed into the constructor) but this will probably change with future versions since they can exist quite happily away from the Map internals.

MM.MouseHandler is a shortcut for

[
    new MM.DragHandler(map),
    new MM.DoubleClickHandler(map),
    new MM.MouseWheelHandler(map)
]

If you want to disable one of these controls, just pass a literal array. A common alternative configuration is just passing Drag and DoubleClick handlers:

[
    new MM.DragHandler(map),
    new MM.DoubleClickHandler(map)
]

On pages where scroll events are noisily intercepted by the map. See also the deadsea project, which aims to provide a smart wrapper around MouseWheel events to prevent this collision.

Touch

MM.TouchHandler provides robust touch support for pinching, dragging, and such.

Advanced Handlers

The MapBox easey project provides more advanced handlers which you can replace Modest Maps's implementations with to get intertial map movements and smooth zooming effects like you'd find in Leaflet or Google Maps.

Clone this wiki locally