diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-10-11 12:59:19 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-10-11 13:05:49 +0200 |
commit | cb5c6fffca8b4663c483d96d7569d28471bf00da (patch) | |
tree | c85970fbc1fb224014eb0c2a1f612280e7b12c9d | |
parent | d63d10c1d256537cc24faaf43ac650e8d7c9f6fe (diff) | |
download | Chimère-cb5c6fffca8b4663c483d96d7569d28471bf00da.tar.bz2 Chimère-cb5c6fffca8b4663c483d96d7569d28471bf00da.zip |
JS: fix routing from a popup
-rw-r--r-- | chimere/static/chimere/js/jquery.chimere.js | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/chimere/static/chimere/js/jquery.chimere.js b/chimere/static/chimere/js/jquery.chimere.js index 5d2cc4d..1f9a347 100644 --- a/chimere/static/chimere/js/jquery.chimere.js +++ b/chimere/static/chimere/js/jquery.chimere.js @@ -596,7 +596,7 @@ function transformCoordToLonLat(coord) { return feature; } ); - settings.current_feature = feature; + if (typeof feature != 'undefined') settings.current_feature = feature; if (!settings.edition){ if (methods._is_popuphovering()) return; $(settings.popup_item).popover('destroy'); @@ -1130,6 +1130,7 @@ function transformCoordToLonLat(coord) { return feature; }, openPopup: function(feature, offset_x, offset_y, alt_coordinates){ + settings.current_feature = feature; if (!offset_x){ offset_x = feature.get('popup_offset_x'); if (!offset_x) offset_x = 0; @@ -1160,6 +1161,7 @@ function transformCoordToLonLat(coord) { }); // when the popup is closed $(settings.popup_item).on('hidden.bs.popover', function () { + settings.current_feature = null; methods._unregister_popuphovering(); }) $(settings.popup_item).popover('show'); @@ -2039,8 +2041,17 @@ function transformCoordToLonLat(coord) { if (settings.routing_start){ settings.sourceRoutingFeatures.removeFeature(settings.routing_start); } + + var coordinates; + if (typeof obj == 'undefined') { + coordinates = settings.popup.getPosition(); + } else { + coordinates = obj.coordinate; + } + if (typeof coordinates == 'undefined') return; + settings.routing_start = new ol.Feature({ - geometry: new ol.geom.Point(obj.coordinate) + geometry: new ol.geom.Point(coordinates) }); if (!settings.icon_start_style){ settings.icon_start_style = new ol.style.Style({ @@ -2057,7 +2068,7 @@ function transformCoordToLonLat(coord) { settings.routingFeatures.push(settings.routing_start); if (nominatim_url){ helpers.updateNominatimName( - transformCoordToLonLat(obj.coordinate), + transformCoordToLonLat(coordinates), 'start_label'); } @@ -2138,8 +2149,16 @@ function transformCoordToLonLat(coord) { $('.map_menu_clear').show(); } + var coordinates; + if (typeof obj == 'undefined') { + coordinates = settings.popup.getPosition(); + } else { + coordinates = obj.coordinate; + } + if (typeof coordinates == 'undefined') return; + var feat = new ol.Feature({ - geometry: new ol.geom.Point(obj.coordinate) + geometry: new ol.geom.Point(coordinates) }); if (!settings.icon_step_style){ settings.icon_step_style = new ol.style.Style({ @@ -2159,7 +2178,7 @@ function transformCoordToLonLat(coord) { if (nominatim_url){ var current_itinerary_number = methods.add_step_fx(); helpers.updateNominatimName( - transformCoordToLonLat(obj.coordinate), + transformCoordToLonLat(coordinates), 'step_'+current_itinerary_number+'_label'); } if (settings.routing_end && settings.routing_start) methods.route(); @@ -2214,8 +2233,17 @@ function transformCoordToLonLat(coord) { if (settings.routing_end){ settings.sourceRoutingFeatures.removeFeature(settings.routing_end); } + + var coordinates; + if (typeof obj == 'undefined') { + coordinates = settings.popup.getPosition(); + } else { + coordinates = obj.coordinate; + } + if (typeof coordinates == 'undefined') return; + settings.routing_end = new ol.Feature({ - geometry: new ol.geom.Point(obj.coordinate) + geometry: new ol.geom.Point(coordinates) }); if (!settings.icon_end_style){ settings.icon_end_style = new ol.style.Style({ @@ -2233,7 +2261,7 @@ function transformCoordToLonLat(coord) { if (nominatim_url){ helpers.updateNominatimName( - transformCoordToLonLat(obj.coordinate), + transformCoordToLonLat(coordinates), 'end_label'); } |