when showing a highlight marker, respective description stays selected
This commit is contained in:
parent
ce1db933f3
commit
54270f5169
@ -38,6 +38,14 @@ show: function() {
|
|||||||
hide: function() {
|
hide: function() {
|
||||||
OSRM.G.map.removeLayer(this.marker);
|
OSRM.G.map.removeLayer(this.marker);
|
||||||
this.shown = false;
|
this.shown = false;
|
||||||
|
|
||||||
|
// revert highlighted description
|
||||||
|
if( this.label == "highlight" )
|
||||||
|
if( this.description ) {
|
||||||
|
var desc = document.getElementById("description-"+this.description);
|
||||||
|
desc && (desc.className = "description-body-item");
|
||||||
|
this.description = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setPosition: function( position ) {
|
setPosition: function( position ) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
@ -393,11 +393,16 @@ html, body
|
|||||||
.description-body-item
|
.description-body-item
|
||||||
{
|
{
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
color:#000000
|
color:#000000;
|
||||||
}
|
}
|
||||||
.description-body-item:hover
|
.description-body-item:hover
|
||||||
{
|
{
|
||||||
color:#ff0000
|
color:#ff0000;
|
||||||
|
}
|
||||||
|
.description-body-item-selected
|
||||||
|
{
|
||||||
|
cursor:pointer;
|
||||||
|
color:#ff00ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
@ -43,10 +43,13 @@ onMouseOverRouteDescription: function(lat, lng) {
|
|||||||
onMouseOutRouteDescription: function(lat, lng) {
|
onMouseOutRouteDescription: function(lat, lng) {
|
||||||
OSRM.G.markers.hover.hide();
|
OSRM.G.markers.hover.hide();
|
||||||
},
|
},
|
||||||
onClickRouteDescription: function(lat, lng) {
|
onClickRouteDescription: function(lat, lng, desc) {
|
||||||
OSRM.G.markers.highlight.setPosition( new L.LatLng(lat, lng) );
|
OSRM.G.markers.highlight.setPosition( new L.LatLng(lat, lng) );
|
||||||
OSRM.G.markers.highlight.show();
|
OSRM.G.markers.highlight.show();
|
||||||
OSRM.G.markers.highlight.centerView(OSRM.DEFAULTS.HIGHLIGHT_ZOOM_LEVEL);
|
OSRM.G.markers.highlight.centerView(OSRM.DEFAULTS.HIGHLIGHT_ZOOM_LEVEL);
|
||||||
|
|
||||||
|
OSRM.G.markers.highlight.description = desc;
|
||||||
|
document.getElementById("description-"+desc).className = "description-body-item description-body-item-selected";
|
||||||
},
|
},
|
||||||
onClickCreateShortcut: function(src){
|
onClickCreateShortcut: function(src){
|
||||||
src += '&z='+ OSRM.G.map.getZoom() + '¢er=' + OSRM.G.map.getCenter().lat.toFixed(6) + ',' + OSRM.G.map.getCenter().lng.toFixed(6);
|
src += '&z='+ OSRM.G.map.getZoom() + '¢er=' + OSRM.G.map.getCenter().lat.toFixed(6) + ',' + OSRM.G.map.getCenter().lng.toFixed(6);
|
||||||
@ -94,6 +97,12 @@ show: function(response) {
|
|||||||
|
|
||||||
// create GPX link
|
// create GPX link
|
||||||
var gpx_link = '[<a class="route-link" onClick="document.location.href=\'' + OSRM.G.active_routing_server_url + query_string + '&output=gpx\';">'+OSRM.loc("GPX_FILE")+'</a>]';
|
var gpx_link = '[<a class="route-link" onClick="document.location.href=\'' + OSRM.G.active_routing_server_url + query_string + '&output=gpx\';">'+OSRM.loc("GPX_FILE")+'</a>]';
|
||||||
|
|
||||||
|
// check highlight marker to get id of corresponding description
|
||||||
|
// [works as changing language or metric does not remove the highlight marker!]
|
||||||
|
var selected_description = null;
|
||||||
|
if( OSRM.G.markers.highlight.isShown() )
|
||||||
|
selected_description = OSRM.G.markers.highlight.description;
|
||||||
|
|
||||||
// create route description
|
// create route description
|
||||||
var positions = OSRM.G.route.getPositions();
|
var positions = OSRM.G.route.getPositions();
|
||||||
@ -112,8 +121,8 @@ show: function(response) {
|
|||||||
|
|
||||||
body += '<td class="description-body-items">';
|
body += '<td class="description-body-items">';
|
||||||
var pos = positions[response.route_instructions[i][3]];
|
var pos = positions[response.route_instructions[i][3]];
|
||||||
body += '<div id="description-'+i+'" class="description-body-item" ' +
|
body += '<div id="description-'+i+'" class="description-body-item '+(selected_description==i ? "description-body-item-selected": "")+'" ' +
|
||||||
'onclick="OSRM.RoutingDescription.onClickRouteDescription('+pos.lat.toFixed(6)+","+pos.lng.toFixed(6)+')" ' +
|
'onclick="OSRM.RoutingDescription.onClickRouteDescription('+pos.lat.toFixed(6)+","+pos.lng.toFixed(6)+","+i+')" ' +
|
||||||
'onmouseover="OSRM.RoutingDescription.onMouseOverRouteDescription('+pos.lat.toFixed(6)+","+pos.lng.toFixed(6)+')" ' +
|
'onmouseover="OSRM.RoutingDescription.onMouseOverRouteDescription('+pos.lat.toFixed(6)+","+pos.lng.toFixed(6)+')" ' +
|
||||||
'onmouseout="OSRM.RoutingDescription.onMouseOutRouteDescription('+pos.lat.toFixed(6)+","+pos.lng.toFixed(6)+')">';
|
'onmouseout="OSRM.RoutingDescription.onMouseOutRouteDescription('+pos.lat.toFixed(6)+","+pos.lng.toFixed(6)+')">';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user