[GIS] OpenLayers OverviewMap not working

map-overviewsopenlayers

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

Best Answer

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
Related Question