What is the overpass query to find all the hospitals in a region?

青春壹個敷衍的年華 提交于 2019-12-13 19:59:02

问题


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:


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.



来源:https://stackoverflow.com/questions/37319048/what-is-the-overpass-query-to-find-all-the-hospitals-in-a-region

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!