Project

General

Profile

1
<html xmlns="http://www.w3.org/1999/xhtml">
2
  <head>
3
    <meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
4
    <style type="text/css">
5
        #map {
6
            width: 100%;
7
            height: 512px;
8
            border: 1px solid black;
9
        }
10
    </style>
11

    
12

    
13
    <script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script>
14

    
15
    <script src="../lib/OpenLayers.js"></script>
16
    <script type="text/javascript">
17
        <!--
18
 
19
        var lon = 5;
20
        var lat = 40;
21
        var zoom = 15;
22
        var map, velayer, layer;
23

    
24
        function init(){
25
            map = new OpenLayers.Map( $('map') , 
26
            {controls:[new OpenLayers.Control.MouseDefaults()]});
27

    
28
            velayer = new OpenLayers.Layer.VirtualEarth( "VE",
29
            { minZoomLevel: 4, maxZoomLevel: 6 }); 
30
            map.addLayer(velayer);
31
            
32
            markers = new OpenLayers.Layer.Markers("markers");
33
            map.addLayer(markers);
34

    
35
            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
36
            map.addControl( new OpenLayers.Control.LayerSwitcher() );
37
            map.addControl( new OpenLayers.Control.PanZoomBar() );
38
        }
39
        
40
        function add() {
41
            
42
            marker = new OpenLayers.Marker(new OpenLayers.LonLat(2, 41));
43
            markers.addMarker(marker);
44
        }
45

    
46
        function remove() {
47
            markers.removeMarker(marker);
48
        }
49
  // -->
50
    </script>
51
  </head>
52
  <body onload="init()">
53
    <h1>OpenLayers VE Example</h1>
54
    <div id="map"></div>
55
    <div style="background-color:green" onclick="add()"> click to add the marker to the map</div>
56
    <div style="background-color:red" onclick="remove()"> click to remove the marker from the map</div>
57
  </body>
58
</html>
(28-28/35)