[OpenLayers-Users] Beginner Virtual Earth Problems

Richard Marsden richard at winwaed.com
Fri May 2 17:06:04 EDT 2008


I am currently using MapServer and OpenLayers for an online mapping 
project to display a rain forest study area - unfortunately I'm a bit 
of  a beginner with both! I'm currently having problems using Virtual 
Earth in OpenLayers: in particular switching between layers, and with VE 
versions.

Virtual Earth isn't suitable for the main map because our study area is 
only about 10ha of Costa Rican rain forest - ie. the detail just isn't 
there. However, I am try to use Virtual Earth as an optional base map to 
show the study area in context.

I've managed to get the OpenLayers Virtual Earth sample working with a 
MapServer WMS hydrology overlay ('synthetic streams').
I'm currently trying to get it to work with an alternative "outline map".

Ie. there are two base layers that can be chosen with a pair of radio 
buttons in the LayerSwitcher:  'Virtual Earth Base Layer',  and  
'Outline'   (WMS delivered shape file)
An optional overlay  is selected with a checkbox:  'Synthetic streams' 
(also via WMS).

This is a work in progress so the colours could be improved, but my 
results are here:

http://www.ecomapcostarica.com/map/map_beta.html

Virtual Earth imagery loads okay at first. Switching to the 'Outline' 
works as well. However, when I switch back to Virtual Earth, it fails to 
re-appear. Instead, Outline is replaced with a white fill.

What am I doing wrong?  Or is this kind of behaviour not supported?

This is my Javascript:

<script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js"></script>

    <script src="./OpenLayers.js"></script>

    <script type="text/javascript">
        var lon = -84;
        var lat = 10;
        var zoom = 7;
        var map;
        var stream_layer, velayer, bound_layer, outline_layer;

        function init(){
            map = new OpenLayers.Map( 'map' );

            velayer = new OpenLayers.Layer.VirtualEarth("Virtual Earth Base Layer", 
{ minZoomLevel: 4, maxZoomLevel: 8, 'type': VEMapStyle.Aerial } );
            map.addLayer(velayer);


            outline_layer = new OpenLayers.Layer.MapServer( "Outline", 
                    "http://www.ecomapcostarica.com/map/mapserv.cgi?map=/usr/home/winwaed/mapdata/cr_outline.map", {layers: 'outline'},
                    {gutter: 15});
            map.addLayer(outline_layer);

            stream_layer = new OpenLayers.Layer.MapServer( "Synthetic Streams", 
                    "http://www.ecomapcostarica.com/map/mapserv.cgi?map=/usr/home/winwaed/mapdata/cr_stream.map", {layers: 'streams', transparent:'true'},
                    {gutter: 15});
            map.addLayer(stream_layer);



            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
            map.addControl( new OpenLayers.Control.LayerSwitcher() );
        }
	          
    </script>


----

I've also tried changing the script to use v6.1 of the Virtual Earth 
Control,  ie.:

<script 
src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1"></script>

The results can be seen here:

http://www.ecomapcostarica.com/map/map_ve.html

The default "North America" map appears  - not my selected area at all, 
and none of the OpenLayers controls (zoom, layer selection, etc) appear.

Is v3 the latest version supported by OpenLayers?  Are there any plans 
to update this in the near future?  I see that Microsoft are actively 
retiring old versions of the Virtual Earth API.

Thanks in advance.  OpenLayers and MapServer are both capable of some 
pretty neat stuff - I have high hopes regarding the final result!


Richard Marsden
Wiwnaed Software Technology LLC
http://www.winwaed.com
http://www.mapping-tools.com










More information about the Users mailing list