[OpenLayers-Users] overviewmap problem: bounds & maxExtent has
no properties
Tim Schaub
tschaub at opengeo.org
Mon Jun 9 15:23:17 EDT 2008
Hey -
(Martin, copying this back to the users list in case it is of use to
someone else.)
The overview map control takes an options argument. The properties of
that options argument configure the control. The overview map control
is a control. It has a reference to a map that acts as the actual
overview. Some of the properties in the options argument configure the
control, and *one* of them configures the map, the mapOptions property.
If you want to pass an options argument in that has properties for both
configuring the control and configuring the map that the control has, do
so with something like:
var options = {
layers: [somelayer],
minRatio: 8, // just an example
mapOptions: {
projection: someproj,
units: someunits,
maxExtent: somebounds // etc.
}
};
var control = new OpenLayers.Control.OverviewMap(options);
Make sense?
Tim
PS - The one bit of weirdness you might notice is that you configure the
layers as a property on the control, but they become a property of the
map that the control creates. This is consistent with the
OpenLayers.Map constructor - which doesn't allow you to specify layers
in the options argument. No particular reason for that, it just doesn't
work currently.
Martin Ouellet wrote:
> First, thanks for your comments and you were right about some useless
> parameter in my code, Ive changed that...
>
> For the rest, I still cannot make it work???
>
> If I understand correctly, the custom layer (different from the
> baselayer) must be specify in the "options" tag og the overview control?
> So this would be:
>
> var jpl_wms = new OpenLayers.Layer.WMS( "wms",
> "my url",
> {layers: "muncipipalite"});
> var options = {layers: [jpl_wms]};
>
> map.addControl(new OpenLayers.Control.OverviewMap(options));
>
> In second part, since I'am using a custom projection (map and overview),
> I have to specify my parameter in the "mapOptions" tag of the overview
> control?
> In my case:
>
> // Construct overview map with non-default projection, units, and extent
> var options = {
> projection: "EPSG:42105",
> units: 'm',
> maxExtent: new OpenLayers.Bounds(30000, 75000, 1709360, 2120440)
>
> };
>
> map.addControl(new OpenLayers.Control.OverviewMap({mapOptions: options}));
>
>
> So how can I combine those 2 options when adding the overview control to
> the map?
>
> Thank you in advance for your patience!
>
> MartinO
>
>
>
>
> 2008/6/9 Tim Schaub:
>
> Hey-
>
> Take a closer look at those wiki docs. The solution is there.
>
> A few other comments below...
>
>
> Martin Ouellet wrote:
>
> Yes Tim, I have tried every examples on the overview wiki page.
> Here's my actual config:
>
> *Note that if I used the WMS layer below as the baselayer, the
> overviewmap work just fine. But with the tilecache layer, I
> stil got the two error mentionned earlier...
>
> //BASELAYER MAP OPTIONS
> var map_options = {maxExtent: new OpenLayers.Bounds(30000,
> 75000, 1709360, 2120440),
> maxResolution: 800,
> numZoomLevels: 9,
> projection:"EPSG:42105",
> units: "m",
> controls: [new
> OpenLayers.Control.MouseDefaults()]};
>
>
> The MouseDefaults control is very deprecated. If you want to
> explicitly set controls, use the Navigation control (you may also
> want PanZoom).
>
>
>
> map = new OpenLayers.Map( 'map', map_options);
>
> //BASELAYER DEFINITION
> baseLayer = new OpenLayers.Layer.WMS ( "Carte de base",
>
> ["http://osl1:8080/tilecache/tilecache.py?",
>
> "http://osl2:8080/tilecache/tilecache.py?",
>
> "http://osl3:8080/tilecache/tilecache.py?",
>
> "http://osl4:8080/tilecache/tilecache.py?"],
> { layers : "osl_baselayer",
> map_projection:
> "init=epsg:42105",
> transparent: "true" },
> { isBaseLayer: true }
> );
>
>
> map_projection is not a WMS query string parameter. Unless you have
> done something custom with your TileCache, I think this is of no use
> (I could have missed a change in TileCache).
>
>
>
>
> // WMS OVERVIEW LAYER DEFINITION
> var ovwms = new OpenLayers.Layer.WMS ( "overview",
> "http://blablabla",
> { layers : "municipalite",
> map_projection:
> "init=epsg:42105"},
> { isBaseLayer: false,
> singleTile: true }
> );
>
> // OVERVIEW MAP OPTIONS
> var ov_options = { layers: [ovwms],
> maxExtent: new OpenLayers.Bounds(30000,
> 75000, 1709360, 2120440),
> projection:"EPSG:42105",
> units: "m"
> };
>
> // ADDING THE CONTROL
> map.addControl(new OpenLayers.Control.OverviewMap(ov_options));
>
>
> Keep in mind that the OverviewMap is a control. This control *has*
> a map (it is not a map itself).
>
> When you construct the control, you can set control related options
> and map related options. All map related options go in the
> mapOptions property of the control options. (See the wiki and
> examples for reference.)
>
> Tim
>
>
> does this help?
>
> MartinO
>
> 2008/6/9 Tim Schaub:
>
>
> Hey-
>
> Martin Ouellet wrote:
> > Hi all,
> >
> > I have a tilecache baselayer in a custom projection
> (epsg:42105).
> For
> > the overview map, I have defined a WMS layer (in the same
> projection
> > than the baselayer of course).
> >
> > But at startup, I always get the javascript error:
> "bounds has no
> > properties"
> > and when I zoom in the map:
> "maxExtent
> has no
> > properties"
> >
> > any advice on this?
>
> Depends on how you have configured things.
>
> Have you taken a look at the wiki page for the OverviewMap
> control?
>
> http://trac.openlayers.org/wiki/Control/OverviewMap
>
> Specifically, take a look at the section on non-default
> projections.
>
>
> http://trac.openlayers.org/wiki/Control/OverviewMap#Custommapoptions-projectionsextentsetc.
>
> Tim
>
>
> >
> > MartinO
> >
> >
> >
> >
>
> ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org <mailto:Users at openlayers.org>
> <mailto:Users at openlayers.org <mailto:Users at openlayers.org>>
>
> > http://openlayers.org/mailman/listinfo/users
> >
> >
> >
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org <mailto:Users at openlayers.org>
> <mailto:Users at openlayers.org <mailto:Users at openlayers.org>>
>
> http://openlayers.org/mailman/listinfo/users
>
>
> !DSPAM:4033,484d6fb885321015089218!
>
>
>
> !DSPAM:4033,484d7fc4120487180515871!
More information about the Users
mailing list