[OpenLayers-Users] Overview Map Question

Robert Buzink post at robertbuzink.nl
Tue Jan 9 18:36:55 EST 2007


I came across another problem with the overview-map. It doesn't seem to work
like expected when using a permalink. Following url to following html-page
does show the control, but not the map. After you changed the mapview by
dragging it, the overview-map starts showing.
--------------
http://overviewmap_permalink.html?lat=52.95898&lon=105.18302&zoom=4&layers=BTTT

<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-->
<html xmlns="http://www.w3.org/1999/xhtml">

<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
</head>
<body>
<div style="width:100%; height:100%; " id="map"></div>
<script defer="defer" type="text/javascript">
var map = new OpenLayers.Map('map', { controls: [] });
var metacarta = new OpenLayers.Layer.WMS("Metacarta", "
http://labs.metacarta.com/wms/vmap0", {layers: 'basic'});
map.addLayers([metacarta]);
var options = {
      layers: [metacarta.clone()]};
map.addControl(new OpenLayers.Control.MouseDefaults());
map.setCenter(new OpenLayers.LonLat(5.69083213, 50.84960511), 15);
map.addControl(new OpenLayers.Control.Permalink());
map.addControl(new OpenLayers.Control.OverviewMap(options));
if (!map.getCenter()) map.zoomToMaxExtent();
</script>
</html>
----------------------------------
I guessed the overview-map doesn't work when the center is not set, and that
the permalink unsets the center. But even adding the setCenter after the
permalink (which off course breaks the permalink functionality) does not
make the overview-map show up. So there must be something else bugging the
overview-map.

Is there a way to fix the overview-map behavior for permalinked pages (I
mean outside the api)?

(NB: In the controls
example,<http://openlayers.org/dev/examples/controls.html?lat=5.47119&lon=-5.47119&zoom=6&layers=B0F>the
overviewmap-control just disappears when the map is permalinked. When,
in that script, the controls are added after the layers are added, the
control doesn't disappear, but the overview map doesn't show until you drag
the map, just like in the example above.)


Robert.

On 1/9/07, Robert Buzink <post at robertbuzink.nl> wrote:
>
> hi Tim,
>
> Thanks for the debugging. I know about the adding layers at once. I have
> been writing a php class for openlayers. I first added layers to an array
> every time a baselayer-var was defined and then outputed the array in an
> addlayer-statement at the end of the map, but noticed that openlayers is a
> bit picky about the order of statements (adding controls, adding baselayers,
> setting center, etc.), so I made it more modular and less
> beautiful/efficient.
>
> This shows no overviewmap control at all:
>
> <html>
>     <head>
>         <title>Test</title>
>         <style type="text/css">
>             #map {
>                 width: 512px;
>                 height: 512px;
>                 border: 1px solid gray;
>             }
>         </style>
>         <script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js "
> type="text/javascript"></script>
>     <script src=" http://www.openlayers.org/api/OpenLayers.js"></script>
>     </head>
>     <body>
>         <div id="map"></div>
>         <script defer="defer" type="text/javascript">
>             var map = new OpenLayers.Map('map');
>         var virtualearth = new OpenLayers.Layer.VirtualEarth(
>         "VirtualEarth");
>             var metacarta = new OpenLayers.Layer.WMS(
>                 "Metacarta",
>                 " http://labs.metacarta.com/wms/vmap0",
>                 {layers: 'basic'});
>             map.addLayers([virtualearth,metacarta]);
>             map.addControl (new OpenLayers.Control.OverviewMap());
>             map.setCenter(new OpenLayers.LonLat(5.69, 50.85), 15);
>         </script>
>     </body>
> </html>
>
> This creates weird behaviour (1. overviewmap-control, but no overview-map.
> 2. mouse keeps dragging):
>
> <html>
>     <head>
>         <title>Test</title>
>         <style type="text/css">
>             #map {
>                 width: 512px;
>                 height: 512px;
>                 border: 1px solid gray;
>             }
>         </style>
>         <script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js "
> type="text/javascript"></script>
>     <script src="http://www.openlayers.org/api/OpenLayers.js "></script>
>     <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAmbYSvchg-WUKZ1VciMUQehT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTM_U0Wb-HnwWqFxi6YDlhfBryn8w
>
> <http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAmbYSvchg-WUKZ1VciMUQehT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTM_U0Wb-HnwWqFxi6YDlhfBryn8w>"
> type="text/javascript"></script>
>     </head>
>     <body>
>         <div id="map"></div>
>         <script defer="defer" type="text/javascript">
>             var map = new OpenLayers.Map('map');
>         var google = new OpenLayers.Layer.Google("Google Map");
>
>             var metacarta = new OpenLayers.Layer.WMS(
>                 "Metacarta",
>                 "http://labs.metacarta.com/wms/vmap0",
>                 {layers: 'basic'});
>             map.addLayers([google,metacarta]);
>             map.addControl(new OpenLayers.Control.OverviewMap());
>             map.setCenter(new OpenLayers.LonLat(5.69, 50.85), 15);
>         </script>
>     </body>
> </html>
>
> As you can see, the problem is the baselayer. Whenever it isn't the(/a?)
> wms layer, the overviewmap control breaks. Maybe the overviewmapcontrol
> should default to the metacarta wms baselayer?
>
> I don't know much about the inside of the ol-api, I am just using the
> excellent bricks you provide to build a php/mysql 'application' that
> non-technical users can use and configure. Maybe I could do something back
> by releasing the php-class when it is finished (if there isn't released one
> already)?
>
> Robert,
>



-- 
Robert Buzink, website ontwerp en ontwikkeling
Sint-Pietersaalststraat 123
9000 Gent
+32 (0)9 33 00 267
+32 (0)487 548 414
post at robertbuzink.nl
robertbuzink.nl/webdesign
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070110/6b2bf062/attachment.html


More information about the Users mailing list