leaflet-layer-overpass

WebJar for leaflet-layer-overpass

License

License

MIT
Categories

Categories

Leaf Data Databases
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

leaflet-layer-overpass
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

leaflet-layer-overpass
WebJar for leaflet-layer-overpass
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/kartenkarsten/leaflet-layer-overpass

Download leaflet-layer-overpass

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/leaflet-layer-overpass/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>leaflet-layer-overpass</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/leaflet-layer-overpass/
implementation 'org.webjars.bower:leaflet-layer-overpass:1.0.1'
// https://jarcasting.com/artifacts/org.webjars.bower/leaflet-layer-overpass/
implementation ("org.webjars.bower:leaflet-layer-overpass:1.0.1")
'org.webjars.bower:leaflet-layer-overpass:jar:1.0.1'
<dependency org="org.webjars.bower" name="leaflet-layer-overpass" rev="1.0.1">
  <artifact name="leaflet-layer-overpass" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='leaflet-layer-overpass', version='1.0.1')
)
libraryDependencies += "org.webjars.bower" % "leaflet-layer-overpass" % "1.0.1"
[org.webjars.bower/leaflet-layer-overpass "1.0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.bower : leaflet jar [0.7.3,0.8)

Project Modules

There are no modules declared in this project.

Leaflet Layer OverPass

Bower version

What is it?

A Leaflet plugin to create a custom POI overlay - thanks to the OSM dataset and the Overpass API

checkout the demo

Installation

You can use bower to install leaflet-layer-overpass.

Simply run

$ bower install --save leaflet-layer-overpass

After that you can include and use the OverpassLayer.css and OverpassLayer.js files (or OverPassLayer.min.js if you want the minified version) from the dist folder in your html.

How to use it?

var attr_osm = 'Map data &copy; <a href="http://openstreetmap.org/">OpenStreetMap</a> contributors',
attr_overpass = 'POI via <a href="http://www.overpass-api.de/">Overpass API</a>';
var osm = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {opacity: 0.7, attribution: [attr_osm, attr_overpass].join(', ')});

var map = new L.Map('map').addLayer(osm).setView(new L.LatLng(52.265, 10.524), 14);

//OverPassAPI overlay
var opl = new L.OverPassLayer({
  query: "node(BBOX)['amenity'='post_box'];out;",
});

map.addLayer(opl);

In order to get a valid query the Overpass-turbo IDE might help.

What are the options?

You can specify an options object as an argument of L.OverPassLayer.

options: {
  endpoint: "http://overpass.osm.rambler.ru/cgi/",
  query: "node(BBOX)['amenity'='post_box'];out;",
  debug: false,
  callback: function(data) {
    for(var i=0;i<data.elements.length;i++) {
      var e = data.elements[i];

      if (e.id in this.instance._ids) return;
      this.instance._ids[e.id] = true;
      var pos = new L.LatLng(e.lat, e.lon);
      var popup = this.instance._poiInfo(e.tags,e.id);
      var color = e.tags.collection_times ? 'green':'red';
      var circle = L.circle(pos, 50, {
        color: color,
        fillColor: '#fa3',
        fillOpacity: 0.5
      })
      .bindPopup(popup);
      this.instance.addLayer(circle);
    }
  },
  minZoomIndicatorOptions: {
    position: 'topright',
    minZoomMessageNoLayer: "no layer assigned",
    minZoomMessage: "current Zoom-Level: CURRENTZOOM all data at Level: MINZOOMLEVEL"
  }
};

Used by

Dependencies

  • Leaflet (tried with version 0.6.2, 0.7.3)

Development

In order to contribute to the project you should first clone the repository. The javascript source files reside in the src folder and are concatenated and minified by gulp. If you want to make changes make them in the src folder and then build the dist file with gulp. For that you first need to install gulp if you do not have installed it yet

$ npm install --global gulp

Then install all the needed packages for this project:

$ npm install 

And then just run

gulp

after you made your changes. This will combine (and minify) the files and put them into the dist folder.

Further Ideas

  • OverPass result to -> geoJSON to -> Leaflet Layer to support ways and areas as well (see also PoiMap, OverPassTurbo)
  • improve popup text. use links, format addresses and contact details (compare with OpenLinkMap)
  • improve caching - allow to store data for some days in browser

Versions

Version
1.0.1