//= require_self
//= require_tree ./directions
+//= require querystring
OSM.Directions = function (map) {
+ var querystring = require("querystring-component");
+
var awaitingGeocode; // true if the user has requested a route, but we're waiting on a geocode result
var awaitingRoute; // true if we've asked the engine for a route and are waiting to hear back
var chosenEngine;
endpoint.awaitingGeocode = true;
- $.getJSON(OSM.NOMINATIM_URL + "search?q=" + encodeURIComponent(endpoint.value) + "&format=json", function (json) {
+ var viewbox = map.getBounds().toBBoxString(); // <sw lon>,<sw lat>,<ne lon>,<ne lat>
+
+ $.getJSON(OSM.NOMINATIM_URL + "search?q=" + encodeURIComponent(endpoint.value) + "&format=json&viewbox=" + viewbox, function (json) {
endpoint.awaitingGeocode = false;
endpoint.hasGeocode = true;
if (json.length === 0) {