all images are now loaded in main.js
This commit is contained in:
parent
ea207cef6e
commit
ffd5e2de99
@ -30,6 +30,9 @@ init: function() {
|
||||
OSRM.GUI.visible = true;
|
||||
OSRM.GUI.width = document.getElementById("main-wrapper").clientWidth;
|
||||
|
||||
// init favicon
|
||||
document.getElementById('favicon').href=OSRM.G.images["favicon"].src;
|
||||
|
||||
// init starting source/target
|
||||
document.getElementById('gui-input-source').value = OSRM.DEFAULTS.ONLOAD_SOURCE;
|
||||
document.getElementById('gui-input-target').value = OSRM.DEFAULTS.ONLOAD_TARGET;
|
||||
|
@ -30,7 +30,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
<meta name="author" content="Dennis Schieferdecker" />
|
||||
|
||||
<!-- favicon -->
|
||||
<link rel="shortcut icon" href="images/osrm-favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="" type="image/x-icon" id="favicon"/>
|
||||
|
||||
<!-- stylesheets -->
|
||||
<link rel="stylesheet" href="leaflet/leaflet.css" type="text/css"/>
|
||||
|
@ -27,7 +27,7 @@ OSRM.init = function() {
|
||||
OSRM.Localization.init();
|
||||
OSRM.GUI.init();
|
||||
OSRM.Map.init();
|
||||
OSRM.Routing.init();
|
||||
OSRM.Routing.init();
|
||||
|
||||
// check if the URL contains some GET parameter, e.g. for showing a route
|
||||
OSRM.checkURL();
|
||||
@ -35,40 +35,54 @@ OSRM.init = function() {
|
||||
|
||||
|
||||
// prefetch images
|
||||
OSRM.GLOBALS.images = Array();
|
||||
OSRM.GLOBALS.images = {};
|
||||
OSRM.prefetchImages = function() {
|
||||
var images = [ 'images/marker-source.png',
|
||||
'images/marker-target.png',
|
||||
'images/marker-via.png',
|
||||
'images/marker-highlight.png',
|
||||
'images/marker-source-drag.png',
|
||||
'images/marker-target-drag.png',
|
||||
'images/marker-via-drag.png',
|
||||
'images/marker-highlight-drag.png',
|
||||
'images/marker-drag.png',
|
||||
'images/cancel.png',
|
||||
'images/cancel_active.png',
|
||||
'images/cancel_hover.png',
|
||||
'images/restore.png',
|
||||
'images/restore_active.png',
|
||||
'images/restore_hover.png',
|
||||
'images/printer.png',
|
||||
'images/printer_active.png',
|
||||
'images/printer_hover.png',
|
||||
'images/printer_inactive.png'
|
||||
];
|
||||
|
||||
for(var i=0; i<images.length; i++) {
|
||||
OSRM.G.images[i] = new Image();
|
||||
OSRM.G.images[i].src = images[i];
|
||||
var image_names = [ 'marker-source',
|
||||
'marker-target',
|
||||
'marker-via',
|
||||
'marker-highlight',
|
||||
'marker-source-drag',
|
||||
'marker-target-drag',
|
||||
'marker-via-drag',
|
||||
'marker-highlight-drag',
|
||||
'marker-drag',
|
||||
'cancel',
|
||||
'cancel_active',
|
||||
'cancel_hover',
|
||||
'restore',
|
||||
'restore_active',
|
||||
'restore_hover',
|
||||
'printer',
|
||||
'printer_active',
|
||||
'printer_hover',
|
||||
'printer_inactive',
|
||||
'turn-left',
|
||||
'turn-right',
|
||||
'u-turn',
|
||||
'continue',
|
||||
'slight-left',
|
||||
'slight-right',
|
||||
'sharp-left',
|
||||
'sharp-right',
|
||||
'round-about',
|
||||
'target',
|
||||
'default'
|
||||
];
|
||||
|
||||
for(var i=0; i<image_names.length; i++) {
|
||||
OSRM.G.images[image_names[i]] = new Image();
|
||||
OSRM.G.images[image_names[i]].src = 'images/'+image_names[i]+'.png';
|
||||
}
|
||||
|
||||
OSRM.G.images["favicon"] = new Image();
|
||||
OSRM.G.images["favicon"].src = 'images/osrm-favicon.ico';
|
||||
};
|
||||
|
||||
|
||||
// prefetch icons
|
||||
OSRM.GLOBALS.icons = Array();
|
||||
OSRM.GLOBALS.icons = {};
|
||||
OSRM.prefetchIcons = function() {
|
||||
var images = [ 'marker-source',
|
||||
var image_names = [ 'marker-source',
|
||||
'marker-target',
|
||||
'marker-via',
|
||||
'marker-highlight',
|
||||
@ -79,13 +93,13 @@ OSRM.prefetchIcons = function() {
|
||||
'marker-drag'
|
||||
];
|
||||
|
||||
for(var i=0; i<images.length; i++) {
|
||||
for(var i=0; i<image_names.length; i++) {
|
||||
var icon = {
|
||||
iconUrl: 'images/'+images[i]+'.png', iconSize: new L.Point(25, 41), iconAnchor: new L.Point(13, 41),
|
||||
iconUrl: 'images/'+image_names[i]+'.png', iconSize: new L.Point(25, 41), iconAnchor: new L.Point(13, 41),
|
||||
shadowUrl: L.ROOT_URL + 'images/marker-shadow.png', shadowSize: new L.Point(41, 41),
|
||||
popupAnchor: new L.Point(0, -33)
|
||||
};
|
||||
OSRM.G.icons[images[i]] = new L.SwitchableIcon(icon);
|
||||
OSRM.G.icons[image_names[i]] = new L.SwitchableIcon(icon);
|
||||
}
|
||||
|
||||
// special values for drag marker
|
||||
|
@ -66,7 +66,7 @@ show: function(response) {
|
||||
route_desc += '<tr class="'+rowstyle+'">';
|
||||
|
||||
route_desc += '<td class="result-directions">';
|
||||
route_desc += '<img width="18px" src="images/'+OSRM.RoutingDescription.getDirectionIcon(response.route_instructions[i][0])+'" alt="" />';
|
||||
route_desc += '<img width="18px" src="'+OSRM.G.images[OSRM.RoutingDescription.getDirectionIcon(response.route_instructions[i][0])].src+'" alt="" />';
|
||||
route_desc += "</td>";
|
||||
|
||||
route_desc += '<td class="result-items">';
|
||||
@ -158,33 +158,33 @@ showNA: function( display_text ) {
|
||||
// [TODO: language-safe implementation]
|
||||
getDirectionIcon: function(name) {
|
||||
var directions = {
|
||||
"Turn left":"turn-left.png",
|
||||
"Turn right":"turn-right.png",
|
||||
"U-Turn":"u-turn.png",
|
||||
"Head":"continue.png",
|
||||
"Continue":"continue.png",
|
||||
"Turn slight left":"slight-left.png",
|
||||
"Turn slight right":"slight-right.png",
|
||||
"Turn sharp left":"sharp-left.png",
|
||||
"Turn sharp right":"sharp-right.png",
|
||||
"Enter roundabout and leave at first exit":"round-about.png",
|
||||
"Enter roundabout and leave at second exit":"round-about.png",
|
||||
"Enter roundabout and leave at third exit":"round-about.png",
|
||||
"Enter roundabout and leave at fourth exit":"round-about.png",
|
||||
"Enter roundabout and leave at fifth exit":"round-about.png",
|
||||
"Enter roundabout and leave at sixth exit":"round-about.png",
|
||||
"Enter roundabout and leave at seventh exit":"round-about.png",
|
||||
"Enter roundabout and leave at eighth exit":"round-about.png",
|
||||
"Enter roundabout and leave at nineth exit":"round-about.png",
|
||||
"Enter roundabout and leave at tenth exit":"round-about.png",
|
||||
"Enter roundabout and leave at one of the too many exit":"round-about.png",
|
||||
"You have reached your destination":"target.png"
|
||||
"Turn left":"turn-left",
|
||||
"Turn right":"turn-right",
|
||||
"U-Turn":"u-turn",
|
||||
"Head":"continue",
|
||||
"Continue":"continue",
|
||||
"Turn slight left":"slight-left",
|
||||
"Turn slight right":"slight-right",
|
||||
"Turn sharp left":"sharp-left",
|
||||
"Turn sharp right":"sharp-right",
|
||||
"Enter roundabout and leave at first exit":"round-about",
|
||||
"Enter roundabout and leave at second exit":"round-about",
|
||||
"Enter roundabout and leave at third exit":"round-about",
|
||||
"Enter roundabout and leave at fourth exit":"round-about",
|
||||
"Enter roundabout and leave at fifth exit":"round-about",
|
||||
"Enter roundabout and leave at sixth exit":"round-about",
|
||||
"Enter roundabout and leave at seventh exit":"round-about",
|
||||
"Enter roundabout and leave at eighth exit":"round-about",
|
||||
"Enter roundabout and leave at nineth exit":"round-about",
|
||||
"Enter roundabout and leave at tenth exit":"round-about",
|
||||
"Enter roundabout and leave at one of the too many exit":"round-about",
|
||||
"You have reached your destination":"target"
|
||||
};
|
||||
|
||||
if( directions[name] )
|
||||
return directions[name];
|
||||
else
|
||||
return "default.png";
|
||||
return "default";
|
||||
}
|
||||
|
||||
};
|
@ -48,17 +48,17 @@ reverseRouting: function() {
|
||||
if(OSRM.G.markers.route.length == 1) {
|
||||
if(OSRM.G.markers.route[0].label == OSRM.C.TARGET_LABEL) {
|
||||
OSRM.G.markers.route[0].label = OSRM.C.SOURCE_LABEL;
|
||||
OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-source.png') );
|
||||
OSRM.G.markers.route[0].marker.setIcon( OSRM.G.icons['marker-source'] );
|
||||
} else if(OSRM.G.markers.route[0].label == OSRM.C.SOURCE_LABEL) {
|
||||
OSRM.G.markers.route[0].label = OSRM.C.TARGET_LABEL;
|
||||
OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-target.png') );
|
||||
OSRM.G.markers.route[0].marker.setIcon( OSRM.G.icons['marker-target'] );
|
||||
}
|
||||
} else if(OSRM.G.markers.route.length > 1){
|
||||
OSRM.G.markers.route[0].label = OSRM.C.SOURCE_LABEL;
|
||||
OSRM.G.markers.route[0].marker.setIcon( new L.Icon('images/marker-source.png') );
|
||||
OSRM.G.markers.route[0].marker.setIcon( OSRM.G.icons['marker-source'] );
|
||||
|
||||
OSRM.G.markers.route[OSRM.G.markers.route.length-1].label = OSRM.C.TARGET_LABEL;
|
||||
OSRM.G.markers.route[OSRM.G.markers.route.length-1].marker.setIcon( new L.Icon('images/marker-target.png') );
|
||||
OSRM.G.markers.route[OSRM.G.markers.route.length-1].marker.setIcon( OSRM.G.icons['marker-target'] );
|
||||
}
|
||||
|
||||
// recompute route
|
||||
|
Loading…
Reference in New Issue
Block a user