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 12:59:19 +0200 |
commit | e8e2aadfea4fa4418967237238527ecb39bb5d64 (patch) | |
tree | 99abb39a3d3eef2465626e7b6dba937fdd22d78d | |
parent | c2e9f5e5a870e9dd52cf5dad84157c420994e798 (diff) | |
download | Chimère-e8e2aadfea4fa4418967237238527ecb39bb5d64.tar.bz2 Chimère-e8e2aadfea4fa4418967237238527ecb39bb5d64.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 945b637..85c1142 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'); @@ -2042,8 +2044,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({ @@ -2060,7 +2071,7 @@ function transformCoordToLonLat(coord) { settings.routingFeatures.push(settings.routing_start); if (nominatim_url){ helpers.updateNominatimName( - transformCoordToLonLat(obj.coordinate), + transformCoordToLonLat(coordinates), 'start_label'); } @@ -2141,8 +2152,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({ @@ -2162,7 +2181,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(); @@ -2217,8 +2236,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({ @@ -2236,7 +2264,7 @@ function transformCoordToLonLat(coord) { if (nominatim_url){ helpers.updateNominatimName( - transformCoordToLonLat(obj.coordinate), + transformCoordToLonLat(coordinates), 'end_label'); } |