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? )
returnsthis
show( <GeoJSON> data, <Function> callback? )
returnsthis
toGeoJSON()
returns aGeoJSON FeatureCollection
get( <Number> id )
returns aGeoJSON Feature
orundefined
remove( <GeoJSON or Number> )
returnsthis
edit( <GeoJSON Feature or Number> data, <Function> callback? )
returnsthis
draw( <GeoJSON Feature> data, <Function> callback? )
returnsthis
done()
returnsthis
cancel()
returnsthis
openPopup( <GeoJSON or Number> data, <String> content )
returnsthis
openPopupAt( <GeoJSON or Number> data, <String> content, <Number[]> latLng? )
returnsthis
closePopup()
returnsthis
fit( <GeoJSON or Number> data )
returnsthis
panTo( <GeoJSON or Number> )
returnsthis
selectTileProvider( <String> provider )
returnsthis
clear()
returnsthis
getZoom()
returnsNumber
setZoom( <Number> zoom )
returnsthis
zoomIn( <Number> delta? )
returnsthis
zoomOut( <Number> delta? )
returnsthis
getURL( <GeoJSON Feature> feature )
returnsString
refresh()
returnsthis
location( <Function> onSuccess, <Function> onError )
returnsthis
addButton( <String> id, <String> icon, <Function> callback, <String> title, <String> position? )
returnsthis
removeButton( <String> id )
returnsthis
showButton( <String> id )
returnsthis
hideButton( <String> id )
returnsthis
addLayer( <LayerOption> layer )
returnsthis
showLayer( <Number or LayerOption> id )
returnsthis
hideLayer( <Number or LayerOption> id )
returnsthis
getLayers()
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.