Skip to content
tmcw edited this page Mar 23, 2012 · 4 revisions

Utility Functions

Modest Maps contains a set of utility functions in src/utils.js. This is a minimal set of utilities that are useful to get maps working. Like the rest of MM, they need to be compatible with older browsers like IE7 and FF 3.x.

MM.extend

Used internally for inheritance, MM.extend is sometimes useful for implementing new projections and map providers. For example, to implement

var LinearProjection = function(zoom, transformation) {
    // this is a bit like 'super'
    MM.Projection.call(this, zoom, transformation);
};

LinearProjection.prototype = {
    rawProject: function(point) {
        return new MM.Point(point.x, point.y);
    },
    rawUnproject: function(point) {
        return new MM.Point(point.x, point.y);
    }
};

MM.extend(LinearProjection, MM.Projection);

DOM, CSS

MM uses cancelEvent, addEvent, removeEvent and getStyle functions for normalizing some DOM manipulation.

To respond to events in the map such as panning, zooming, see addCallback.

Clone this wiki locally