0

I'm using Openlayers 4.6 API and the overviewMap function is not working. I'm using Bingmap areial as basemap.

  this.map = new ol.Map
  ({
      controls: [new ol.control.OverviewMap()],  //, attr
      interactions: ol.interaction.defaults
      ({
          doubleClickZoom: false
      }),
      layers: [Bing_layer],
      target: 'map',
      view: view
  });

enter image description here

  • 1
    Problem might be view or bing_layer, I changed two of them, it worked here jsfiddle.net/omurbilgili/eyytw0gc/122 – Ömür Bilgili Mar 12 '18 at 14:59
  • @ÖmürBilgili Thank Omur! That's exactly what the problem is..! I set my Map's view property projection to "EPSG:4326" and left my overView to the default. – MaxG Mar 12 '18 at 15:12
2

So.. I figured out the problem, the ol.control.overviewMap has a view property as well, you will need to make sure the ol.map and the overviewMap has the same view property. In my case, I forgot to set the ol.control.overviewMap's projection. My working sample code is shown below:

var mapView = new ol.View({
  projection: "EPSG:4326",
  center: [-97.5 , 50.5],
  zoom: 7
});
  var overviewView = new ol.View({projection:"EPSG:4326"});

  // Create scaleline control
  var scaleline = new ol.control.ScaleLine();

  var overview = new ol.control.OverviewMap
  ({
    view: overviewView
  });

  // create map interface 

  this.map = new ol.Map
  ({
      controls: [scaleline, overview],  //, attr
      interactions: ol.interaction.defaults
      ({
          doubleClickZoom: false
      }),
      layers: [bing_layer],
      target: 'map',
    view: mapView
  });e

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.