Error when adding OpenLayers.Control.OverviewMap

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Error when adding OpenLayers.Control.OverviewMap

dnbphysicist
All,

I am getting an error when trying to add an overview map to my current map. This is how I am adding the object:

var overviewMap = new OpenLayers.Control.OverviewMap();
map.addControl(overviewMap);

The error:

TypeError: this.baseLayer is null (OpenLayers.debug.js line 9808)
if (this.baseLayer.wrapDateLine) {

I've tried adding a check before the line OL errors on and then adding in the baseLayer from the layers property, and that works, but I don't want to be adding in lines of code to OL. Is there something I can pass into the OverviewMap constructor to fix this?

The actual map renders fine and it does have a baseLayer so I would expect the overview to just inherit that.

Using OL 2.12 and Firefox 17.0.6

Thanks in advance!

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Error when adding OpenLayers.Control.OverviewMap

Alexandre Dubé
Hi Robert,

  Looking at the OverviewMap source code, in the draw method it checks if this.map.baseLayer is defined and won't actually draw the control, nor create the map, unless the baseLayer is set.  I'm not sure what's going on here, but it could be related to something else.

  You could try adding your control after initializing your main map view (extent / center) and see if it works.  You could also try to put a breakpoint on this line using firebug and look at the call stack to see when this gets called and why.  The line you refer is inside the map zoomToExtent method.  See what calls it and why.

HTH,

Alexandre


On 13-07-08 01:11 PM, Rob Hyx wrote:
All,

I am getting an error when trying to add an overview map to my current map. This is how I am adding the object:

var overviewMap = new OpenLayers.Control.OverviewMap();
map.addControl(overviewMap);

The error:

TypeError: this.baseLayer is null (OpenLayers.debug.js line 9808)
if (this.baseLayer.wrapDateLine) {

I've tried adding a check before the line OL errors on and then adding in the baseLayer from the layers property, and that works, but I don't want to be adding in lines of code to OL. Is there something I can pass into the OverviewMap constructor to fix this?

The actual map renders fine and it does have a baseLayer so I would expect the overview to just inherit that.

Using OL 2.12 and Firefox 17.0.6

Thanks in advance!


_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users


-- 
Alexandre Dubé
Mapgears
www.mapgears.com

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Error when adding OpenLayers.Control.OverviewMap

dnbphysicist
Alexandre, thanks for your reply.

I did try adding the control in via Firebug just from the console after the page has fully loaded and I get the same error. From looking at the call stack in FB:

zoomToExtent(bounds=-180,-90,180,90 { left=-180, bottom=-90, right=180, more...}, closest=undefined)
zoomToMaxExtent(options=undefined)
createMap()
update()
draw()
addControlToMap(control=Object { layers=[1], handlers={...}, displayClass="olControlOverviewMap", more...}, px=undefined)
addControl(control=Object { layers=[1], handlers={...}, displayClass="olControlOverviewMap", more...}, px=undefined)

So it's the call to zoomToMaxExtent() in createMap() that does it. I can see in draw() that there are layers being assigned to the overview (the baseLayer of the the actual map object), but no baseLayer property.


On Mon, Jul 8, 2013 at 1:52 PM, Alexandre Dubé <[hidden email]> wrote:
Hi Robert,

  Looking at the OverviewMap source code, in the draw method it checks if this.map.baseLayer is defined and won't actually draw the control, nor create the map, unless the baseLayer is set.  I'm not sure what's going on here, but it could be related to something else.

  You could try adding your control after initializing your main map view (extent / center) and see if it works.  You could also try to put a breakpoint on this line using firebug and look at the call stack to see when this gets called and why.  The line you refer is inside the map zoomToExtent method.  See what calls it and why.

HTH,

Alexandre



On 13-07-08 01:11 PM, Rob Hyx wrote:
All,

I am getting an error when trying to add an overview map to my current map. This is how I am adding the object:

var overviewMap = new OpenLayers.Control.OverviewMap();
map.addControl(overviewMap);

The error:

TypeError: this.baseLayer is null (OpenLayers.debug.js line 9808)
if (this.baseLayer.wrapDateLine) {

I've tried adding a check before the line OL errors on and then adding in the baseLayer from the layers property, and that works, but I don't want to be adding in lines of code to OL. Is there something I can pass into the OverviewMap constructor to fix this?

The actual map renders fine and it does have a baseLayer so I would expect the overview to just inherit that.

Using OL 2.12 and Firefox 17.0.6

Thanks in advance!


_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users


-- 
Alexandre Dubé
Mapgears
www.mapgears.com

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users




--
HYX

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Error when adding OpenLayers.Control.OverviewMap

Alexandre Dubé
Hi Robert,

  You could try to create your overview map with its own layers:

  new OpenLayers.Control.OverviewMap({
    layers: [
      new OpenLayers.Layer...
    ]
  });

HTH,

Alexandre


On 13-07-10 07:34 AM, Rob Hyx wrote:
Alexandre, thanks for your reply.

I did try adding the control in via Firebug just from the console after the page has fully loaded and I get the same error. From looking at the call stack in FB:

zoomToExtent(bounds=-180,-90,180,90 { left=-180, bottom=-90, right=180, more...}, closest=undefined)
zoomToMaxExtent(options=undefined)
createMap()
update()
draw()
addControlToMap(control=Object { layers=[1], handlers={...}, displayClass="olControlOverviewMap", more...}, px=undefined)
addControl(control=Object { layers=[1], handlers={...}, displayClass="olControlOverviewMap", more...}, px=undefined)

So it's the call to zoomToMaxExtent() in createMap() that does it. I can see in draw() that there are layers being assigned to the overview (the baseLayer of the the actual map object), but no baseLayer property.


-- 
Alexandre Dubé
Mapgears
www.mapgears.com

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Error when adding OpenLayers.Control.OverviewMap

Claudio V.
I second Alexandre, i think you'll need to add some layers on the constructor. The overview control expects a base layer to be set or that you supply some, otherwise it'll have nothing to display.


2013/7/10 Alexandre Dubé <[hidden email]>
Hi Robert,

  You could try to create your overview map with its own layers:

  new OpenLayers.Control.OverviewMap({
    layers: [
      new OpenLayers.Layer...
    ]
  });

HTH,

Alexandre



On 13-07-10 07:34 AM, Rob Hyx wrote:
Alexandre, thanks for your reply.

I did try adding the control in via Firebug just from the console after the page has fully loaded and I get the same error. From looking at the call stack in FB:

zoomToExtent(bounds=-180,-90,180,90 { left=-180, bottom=-90, right=180, more...}, closest=undefined)
zoomToMaxExtent(options=undefined)
createMap()
update()
draw()
addControlToMap(control=Object { layers=[1], handlers={...}, displayClass="olControlOverviewMap", more...}, px=undefined)
addControl(control=Object { layers=[1], handlers={...}, displayClass="olControlOverviewMap", more...}, px=undefined)

So it's the call to zoomToMaxExtent() in createMap() that does it. I can see in draw() that there are layers being assigned to the overview (the baseLayer of the the actual map object), but no baseLayer property.


-- 
Alexandre Dubé
Mapgears
www.mapgears.com

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users



_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users