Skip to content
tmcw edited this page Jan 18, 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

These are likely to change or be replaced with an existing toolkit but are currently available for helping manage cross browser DOM event handling and CSS style querying. For the record, they are cancelEvent, addEvent, removeEvent and getStyle.

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

Clone this wiki locally