mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-20 23:44:47 +02:00
Change search to use OSM Nominatim API
This commit is contained in:
@@ -346,6 +346,10 @@ iD.Map = function(context) {
|
||||
vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2,
|
||||
newZoom = map.zoom() - Math.max(hZoomDiff, vZoomDiff);
|
||||
|
||||
if(newZoom > 19){
|
||||
newZoom = 19;
|
||||
}
|
||||
|
||||
map.centerZoom(extent.center(), newZoom);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,18 +6,19 @@ iD.ui.geocoder = function() {
|
||||
function keydown() {
|
||||
if (d3.event.keyCode !== 13) return;
|
||||
d3.event.preventDefault();
|
||||
d3.json('http://a.tiles.mapbox.com/v3/openstreetmap.map-hn253zqn/geocode/' +
|
||||
encodeURIComponent(this.value) + '.json', function(err, resp) {
|
||||
var searchVal = this.value;
|
||||
d3.json('http://nominatim.openstreetmap.org/search/' +
|
||||
encodeURIComponent(searchVal) + '?limit=10&format=json', function(err, resp) {
|
||||
if (err) return hide();
|
||||
hide();
|
||||
if (!resp.results.length) {
|
||||
if (!resp.length) {
|
||||
return iD.ui.flash()
|
||||
.select('.content')
|
||||
.append('h3')
|
||||
.text('No location found for "' + resp.query[0] + '"');
|
||||
.text('No location found for "' + searchVal + '"');
|
||||
}
|
||||
var bounds = resp.results[0][0].bounds;
|
||||
map.extent(iD.geo.Extent([bounds[0], bounds[1]], [bounds[2], bounds[3]]));
|
||||
var bounds = resp[0].boundingbox;
|
||||
map.extent(iD.geo.Extent([parseFloat(bounds[3]), parseFloat(bounds[0])], [parseFloat(bounds[2]), parseFloat(bounds[1])]));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user