Javascript library for Meppit's map component.
// initialize the map on the "map_container" div with a given center and zoom
var map = new Meppit.Map({
element: 'map_container',
center: [48.858333, 2.294444],
zoom: 13,
mapboxToken: 'your mapbox.com api token'
});| Option | Type | Default | Description |
|---|---|---|---|
| element | String or HTMLElement |
an unattached DIV element | The HTML element used to draw the map |
| zoom | Number |
14 |
Initial map zoom |
| center | Number[] |
[-23.5, -46.6167] |
Initial geographical center of the map |
| tileProvider | String |
'map' |
The name of predefined tile provider the map will use |
| idPropertyName | String |
'id' |
The name of GeoJSON's features property containing the id |
| urlPropertyName | String |
'url' |
The name of GeoJSON's feature property containing the url |
| featureURL | String |
'#{baseURL}features/#{id}' |
The URL used to retrieve a feature GeoJSON |
| geojsonTileURL | String |
'#{baseURL}geoJSON/{z}/{x}/{y}' |
The URL used to retrieve features for a given tile coordinates |
| enableEditor | Boolean |
true |
Whether the features can be edited and drawn |
| enablePopup | Boolean |
true |
Whether a popup should be shown when a features is clicked |
| enableGeoJsonTile | Boolean |
false |
Whether features will be loaded automatically |
| layers | LayerOption[] |
undefined | List of layers used to group features |
| mapboxToken | String |
undefined | You mapbox.com api token (required) |
load( <GeoJSON> data, <Function> callback? )returnsthisshow( <GeoJSON> data, <Function> callback? )returnsthistoGeoJSON()returns aGeoJSON FeatureCollectionget( <Number> id )returns aGeoJSON Featureorundefinedremove( <GeoJSON or Number> )returnsthisedit( <GeoJSON Feature or Number> data, <Function> callback? )returnsthisdraw( <GeoJSON Feature> data, <Function> callback? )returnsthisdone()returnsthiscancel()returnsthisopenPopup( <GeoJSON or Number> data, <String> content )returnsthisopenPopupAt( <GeoJSON or Number> data, <String> content, <Number[]> latLng? )returnsthisclosePopup()returnsthisfit( <GeoJSON or Number> data )returnsthispanTo( <GeoJSON or Number> )returnsthisselectTileProvider( <String> provider )returnsthisclear()returnsthisgetZoom()returnsNumbersetZoom( <Number> zoom )returnsthiszoomIn( <Number> delta? )returnsthiszoomOut( <Number> delta? )returnsthisgetURL( <GeoJSON Feature> feature )returnsStringrefresh()returnsthislocation( <Function> onSuccess, <Function> onError )returnsthisaddButton( <String> id, <String> icon, <Function> callback, <String> title, <String> position? )returnsthisremoveButton( <String> id )returnsthisshowButton( <String> id )returnsthishideButton( <String> id )returnsthisaddLayer( <LayerOption> layer )returnsthisshowLayer( <Number or LayerOption> id )returnsthishideLayer( <Number or LayerOption> id )returnsthisgetLayers()returnsGroup[]destroy()returnsundefined
Indent your code with 2 spaces, strip trailing whitespace and take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Also, please don't edit files in the "dist" subdirectory as they are generated via grunt. You'll find source code in the "src" subdirectory!
Steps to contribute:
- Fork it
- Create your feature branch
git checkout -b my-new-feature - Commit your changes
git commit -am 'Add some feature' - Push to the branch
git push origin my-new-feature - Create new Pull Request
We'll do our best to help you out with any contribution issues you may have.
To contribute you will have to install some development dependencies. This assume you already have Node.js and npm installed on your system.
$ sudo npm install -g grunt-cli
$ npm install
Finally, you will be ready to develop and contribute :)
$ grunt test
$ grunt build
MIT. See LICENSE.txt in this directory.