Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/openstreetmap/leaflet-osm
OpenStreetMap plugin for Leaflet
https://github.com/openstreetmap/leaflet-osm
Last synced: 3 months ago
JSON representation
OpenStreetMap plugin for Leaflet
- Host: GitHub
- URL: https://github.com/openstreetmap/leaflet-osm
- Owner: openstreetmap
- License: other
- Created: 2012-10-09T04:02:39.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2024-05-12T23:05:26.000Z (6 months ago)
- Last Synced: 2024-07-17T00:04:31.160Z (4 months ago)
- Language: JavaScript
- Size: 39.1 KB
- Stars: 109
- Watchers: 15
- Forks: 30
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
leaflet-osm is a [Leaflet](http://leaflet.cloudmade.com/) plugin for rendering
tile and vector data from openstreetmap.org.For example, the openstreetmap.org website could use it to highlight a particular
[way](http://www.openstreetmap.org/?way=52477381) or [node](http://www.openstreetmap.org/?node=164979149)
on the base map.## Usage Examples
### Tile Layers
```js
new L.OSM.Mapnik().addTo(map);// L.OSM.CycleMap and L.OSM.TransportMap require an API key:
// http://www.thunderforest.com/blog/apikeys-now-available/
new L.OSM.CycleMap({apikey: '...'}).addTo(map);
new L.OSM.TransportMap({apikey: '...'}).addTo(map);
```### Data Layer
```js
$.ajax({
url: "http://www.openstreetmap.org/api/0.6/node/164979149",
// or "http://www.openstreetmap.org/api/0.6/way/52477381/full"
dataType: "xml",
success: function (xml) {
var layer = new L.OSM.DataLayer(xml).addTo(map);
map.fitBounds(layer.getBounds());
}
});
```## Contributing
leaflet-osm is tested with node.js using [mocha](http://mochajs.org/) and [chai](http://chaijs.com/):
```bash
$ npm install -g mocha
$ npm install
$ mocha
```## License
Copyright 2012 John Firebaugh
BSD License (see the BSD-LICENSE file)
Portions derived from [OpenLayers](https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Format/OSM.js).
See BSD-LICENSE for details.