0

Location never changes, even with changed lat/long location.

Can someone suggest to me what needs to be done?

var geojsonObject = {

  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [
          -1.0107421875,
          5.703447982149503
        ]
      }
    }
  ]
};

var vectorSource = new ol.source.Vector({
  features: 
  (new ol.format.GeoJSON()).readFeatures(geojsonObject, {dataProjection: 'EPSG:4326'})
});

var vectorLayer = new ol.layer.Vector({
  source: vectorSource,
  // style: styleFunction
});

var map = new ol.Map({
  layers: [
    new ol.layer.Tile({
      source: new ol.source.OSM()
    }),
    vectorLayer
  ],
  target: 'map',
  controls: ol.control.defaults({
    attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
      collapsible: false
    })
  }),
  view: new ol.View({
    center: [0, 8.34],
    zoom: 5
  })
});
2
  • Which location you want to change? The view.center property or the location of the geojson object? In case you test it on your local machine, did you try deleting the cache before reloading your file(s)? Aug 11, 2017 at 16:36
  • Can you provide some example locations?
    – Emily
    Aug 18, 2017 at 18:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.