aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorThomas Haddad2017-01-20 18:03:57 +0100
committerThomas Haddad2017-01-20 18:03:57 +0100
commitd5e47a69756ff4a44c667450c9b79f62f7809b87 (patch)
treedced152cac701f163b1d9d4a70ab09767a11d396 /app/assets/javascripts
parent999ae8f20e1aefac46108c98aa0ef681d49d344c (diff)
downloadchouette-core-d5e47a69756ff4a44c667450c9b79f62f7809b87.tar.bz2
Refs #2405: Fix json layer doesn't need extent anymore (uses fake data for the moment)
Signed-off-by: Thomas Shawarma Haddad <thomas.haddad@af83.com>
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js70
1 files changed, 40 insertions, 30 deletions
diff --git a/app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js b/app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js
index 045183ada..7f314b149 100644
--- a/app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js
+++ b/app/assets/javascripts/es6_browserified/itineraries/components/OlMap.js
@@ -10,56 +10,66 @@ class OlMap extends Component{
fetchApiForMap(extent, id){
const origin = window.location.origin
const path = window.location.pathname.split('/', 3).join('/')
- let params = []
- for ( var i = 0; i < extent.length; i++ )
- params.push(encodeURIComponent(i) + '=' + encodeURIComponent(extent[i]))
- params = params.join("&")
- const urlJSON = origin + path + "/autocomplete_stop_areas/" + id + "/around?" + params
+ return origin + path + "/autocomplete_stop_areas/" + id + "/around"
-
- let req = new Request(urlJSON, {
- credentials: 'same-origin',
- method: 'GET',
- contentType: 'application/json; charset=utf-8',
- Accept: 'application/json',
- headers: {
- 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
- }
- })
- fetch(req)
- .then(response => {
- if(!response.ok) {
- return false
- }
- return response.json()
- }).then((json) => {
- console.log(json)
- })
+ // let req = new Request(urlJSON, {
+ // credentials: 'same-origin',
+ // method: 'GET',
+ // contentType: 'application/json; charset=utf-8',
+ // Accept: 'application/json',
+ // headers: {
+ // 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
+ // }
+ // })
+ // fetch(req)
+ // .then(response => {
+ // if(!response.ok) {
+ // return false
+ // }
+ // return response.json()
+ // }).then((json) => {
+ // console.log(json)
+ // })
}
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/7dcc32af24feea2fc4a329445c91af17/raw/4346a71a37326f055ff4fe576eaeb0040596c916/5.geojson'
+ }),
+ style: new ol.style.Style({
+ image: new ol.style.Circle(({
+ radius: 4,
+ fill: new ol.style.Fill({
+ color: '#000000'
+ })
+ }))
+ })
+ });
var map = new ol.Map({
target: 'stoppoint_map' + that.props.index,
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
- })
+ }),
+ vectorLayer
],
controls: [ new ol.control.ScaleLine() ],
interactions: ol.interaction.defaults({
dragPan: false
}),
view: new ol.View({
- center: ol.proj.fromLonLat([2.349014, 48.864716]),
+ center: ol.proj.fromLonLat([2.3477774, 48.869183, ]),
zoom: 18
})
});
- let extent = map.getView().calculateExtent(map.getSize())
- setTimeout(()=>{
- that.fetchApiForMap(extent, that.props.value.stoparea_id)
- }, 1000)
+ // let extent = map.getView().calculateExtent(map.getSize())
+ // setTimeout(()=>{
+ // that.fetchApiForMap(extent, that.props.value.stoparea_id)
+ // }, 1000)
// TODO when fetching, use extent value in EPSG 4326
// var extent = map.getView().calculateExtent(map.getSize());
}