What is the overpass query to find all the hospita

2019-08-14 23:19发布

I just want to mark all the hospitals in a given LatLog. I tried a lot. But can't find what is my mistake.

var lat = 12.933;
var lon = 77.612;
var zoom = 13;
var map;

function init() {
  map = new OpenLayers.Map("demoMap", {
    controls: [
      new OpenLayers.Control.Navigation(),
      new OpenLayers.Control.PanZoomBar(),
      new OpenLayers.Control.LayerSwitcher(),
      new OpenLayers.Control.Attribution()
    ],
    maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
    maxResolution: 156543.0399,
    numZoomLevels: 19,
    units: 'm',
    projection: new OpenLayers.Projection("EPSG:900913"),
    displayProjection: new OpenLayers.Projection("EPSG:4326")
  });

  layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
  map.addLayer(layerMapnik);

  var lonLat = new OpenLayers.LonLat(lon, lat)
    .transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));

  map.setCenter(lonLat, zoom);

  map.addLayers([
    make_layer("http://overpass-api.de/api/interpreter?data=node[amenity=hospital];out+skel;", "red")
  ]);
}

It does not show any result. Is this because of error in query or any other issue?

1条回答
我只想做你的唯一
2楼-- · 2019-08-15 00:15

You forgot the (bbox) to restrict your data to the current bounding box. As you're querying data for the whole planet, the query will most likely terminate with a timeout or out of memory.

See this link for some examples on how to add (bbox): http://overpass-api.de/open_layers_mashup.html

Before embedding any Overpass queries in your own code, be sure to run it through http://overpass-turbo.eu/ first. Syntax may be slightly different, but it helps to evaluate the results without doing any coding upfront.

查看更多
登录 后发表回答