-
Notifications
You must be signed in to change notification settings - Fork 0
Implementing a custom Engine
Engine is a wrapper of a map API. For example, GoogleEngine is a wrapper for Google Maps API.
All engines have common MapWrapper interface and extend the Engine class, and they call “native” Google, Yahoo, Yandex and whatever API in its implementation.
MapWrapper provides an easy way to implement your own engine.
Special attention was paid on the simplicity of this process.
One may need to implement an engine in two cases:
- If there is a Map API which is not implemented in the MapWrapper lib. For example, Wikimapia is heard to have an API (though very awkward for the time being), but MapWrapper doesn’t have an engine for it. You may want to add it.
- If you want to change the behavior of an existing engine.
The easiest way of implementing a custom engine is to look into existing implementations: google_engine.js, yandex_engine.js, yahoo_engine.js. These are very simple indeed.
But anyway see below the formal description of the Engine interface.
You may use these fields if you need, but don’t override them, as they are heavily relied on in the MapWrapper class.
You don’t need and shouldn’t declare these fields when implementing your own engine. They are declared and initialized in MapWrapper.addEngine().
-
mapWrapper– link to the MapWrapper, to which this Engine was added. -
container– the DOM element (DIV) which contains this engine. It is also passed to *Engine.initialize and is used to indicate, where the map is to be placed.