[OpenLayers-Users] Error when adding OpenLayers.Control.OverviewMap

Rob Hyx robhyx at gmail.com
Wed Jul 10 04:34:49 PDT 2013


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é <adube at mapgears.com> 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!
>
> --
> *HYX*
> http://hyx-music.com
>
>
> _______________________________________________
> Users mailing listUsers at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>
>
> --
> Alexandre Dubé
> Mapgearswww.mapgears.com
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>


-- 
*HYX*
http://hyx-music.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130710/5b4939e6/attachment-0001.html>


More information about the Users mailing list