/* * Open Source Routing Machine (OSRM) - Web (GUI) Interface * Copyright (C) Pascal Neis, 2011 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU AFFERO General Public License as published by * the Free Software Foundation; either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * or see http://www.gnu.org/licenses/agpl.txt. */ /** * Title: Geocode.js * Description: JS file for geocoding * * @author Pascal Neis, pascal@neis-one.org * @version 0.1 2011-05-15 */ //====================== // OBJECTS var HOST_GEOCODE_URL = 'http://open.mapquestapi.com'; var GEOCODE_POST = HOST_GEOCODE_URL + '/nominatim/v1/search?format=json&json_callback=showResultsGeocode'; var searchType = 'search'; var isStartPointSet = false; var isEndPointSet = false; //====================== // FUNCTIONS /* * geocodeAddress()-Function to read out textfield and send request to a OSM nominatim geocoder */ function geocodeAddress(tf){ var freeform; if(tf == 'start'){ freeform = document.getElementById('tfStartSearch').value; } if(tf == 'end'){ freeform = document.getElementById('tfEndSearch').value; } document.getElementById('information').style.visibility = 'visible'; document.getElementById('information').innerHTML = '
One moment please ...
'; var newURL = GEOCODE_POST + "&q="+freeform; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = newURL; document.body.appendChild(script); } /* * showResultsGeocode()-Function to show the geocode result in a div */ function showResultsGeocode(response) { var html = ''; var lonlat = ''; if(response){ html += 'Search Results:
'; html += ''+resultNum+' | '; html += '';
if(result.display_name){
var new_display_name = result.display_name;//.replace(/,/g, ", ") html += ''+new_display_name.trim()+''; } html += " |