diff options
3 files changed, 9 insertions, 6 deletions
diff --git a/app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js b/app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js index b22a95a02..8c52e9090 100644 --- a/app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js +++ b/app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js @@ -7,7 +7,7 @@ class OlMap extends Component{ super(props) } - fetchApiForMap(extent, id){ + fetchApiURL(id){ const origin = window.location.origin const path = window.location.pathname.split('/', 3).join('/') return origin + path + "/autocomplete_stop_areas/" + id + "/around" @@ -15,11 +15,10 @@ class OlMap extends Component{ componentDidUpdate(prevProps, prevState){ if(prevProps.value.olMap.isOpened == false && this.props.value.olMap.isOpened == true){ - var that = this var vectorLayer = new ol.layer.Vector({ source: new ol.source.Vector({ format: new ol.format.GeoJSON(), - url: 'https://gist.githubusercontent.com/ThomasHaddad/d9373a76675d630ba98a6fccb51e12b2/raw/d3356d4dbbcd42942d1b3d36518c014a1ca688b0/itineraries_test.geojson' + url: this.fetchApiURL(this.props.value.stoparea_id) }), style: new ol.style.Style({ image: new ol.style.Circle(({ @@ -32,7 +31,7 @@ class OlMap extends Component{ }) }); var map = new ol.Map({ - target: 'stoppoint_map' + that.props.index, + target: 'stoppoint_map' + this.props.index, layers: [ new ol.layer.Tile({ source: new ol.source.OSM() @@ -47,7 +46,7 @@ class OlMap extends Component{ mouseWheelZoom: false }), view: new ol.View({ - center: ol.proj.fromLonLat([2.3477774, 48.869183, ]), + center: ol.proj.fromLonLat([this.props.value.longitude, this.props.value.latitude ]), zoom: 18 }) }); diff --git a/app/assets/javascripts/es6_browserified/itineraries/index.js b/app/assets/javascripts/es6_browserified/itineraries/index.js index e0f5d0bc7..c7d8eac40 100644 --- a/app/assets/javascripts/es6_browserified/itineraries/index.js +++ b/app/assets/javascripts/es6_browserified/itineraries/index.js @@ -31,6 +31,8 @@ const getInitialState = () => { text: fancyText, for_boarding: value.for_boarding || "normal", for_alighting: value.for_alighting || "normal", + longitude: value.longitude || 0, + latitude: value.latitude || 0, olMap: { isOpened: false, json: {} diff --git a/app/views/autocomplete_stop_areas/index.rabl b/app/views/autocomplete_stop_areas/index.rabl index adec16cff..5b58b04c7 100644 --- a/app/views/autocomplete_stop_areas/index.rabl +++ b/app/views/autocomplete_stop_areas/index.rabl @@ -10,7 +10,9 @@ node do |stop_area| :zip_code => stop_area.zip_code || "", :city_name => stop_area.city_name || "", :short_city_name => truncate(stop_area.city_name, :length => 15) || "", - :user_objectid => stop_area.user_objectid + :user_objectid => stop_area.user_objectid, + :longitude => stop_area.longitude, + :latitude => stop_area.latitude } end |
