/* 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. */ // OSRM initialization // [initialization of maps, local strings, image prefetching] // will hold the Leaflet map object OSRM.GLOBALS.map = null; // onload initialization routine function init() { prefetchImages(); prefetchIcons(); initLocale(); initMap(); initRouting(); // check if the URL contains some GET parameter, e.g. for the route checkURL(); } // prefetch images OSRM.images = Array(); function prefetchImages() { var images = [ 'images/marker-source.png', 'images/marker-target.png', 'images/marker-via.png', 'images/marker-highlight.png', 'images/cancel.png', 'images/cancel_active.png', 'images/cancel_hover.png', 'images/restore.png', 'images/restore_active.png', 'images/restore_hover.png' ]; for(var i=0; i 1000 || called_url.length == 0) return; // storage for parameter values var positions = []; var zoom = null; var center = null; var destination = null; var destination_name = null; // parse input var splitted_url = called_url.split('&'); for(var i=0; i]+(>|$)/g ,""); // discard tags } else if(name_val[0] == 'zoom') { zoom = name_val[1]; if( zoom<0 || zoom > 18) return; } else if(name_val[0] == 'center') { var coordinates = unescape(name_val[1]).split(','); if(coordinates.length!=2 || !isLatitude(coordinates[0]) || !isLongitude(coordinates[1]) ) return; center = new L.LatLng( coordinates[0], coordinates[1]); } } // case 1: destination given if( destination != undefined ) { onclickGeocoderResult(OSRM.C.TARGET_LABEL, destination.lat, destination.lng, (destination_name == undefined) ); if( destination_name != undefined ) document.getElementById("input-target-name").value = destination_name; return; } // case 2: locations given if( positions != []) { // draw via points if( positions.length > 0) { onclickGeocoderResult(OSRM.C.SOURCE_LABEL, positions[0].lat, positions[0].lng, true, false ); //OSRM.G.markers.setSource( positions[0] ); } if(positions.length > 1) { onclickGeocoderResult(OSRM.C.TARGET_LABEL, positions[positions.length-1].lat, positions[positions.length-1].lng, true, false ); //OSRM.G.markers.setTarget( positions[positions.length-1] ); } for(var i=1; i