git-svn-id: http://svn.openlayers.org/trunk/openlayers@806 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
53 lines
1.6 KiB
HTML
53 lines
1.6 KiB
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
|
|
<style type="text/css">
|
|
#map {
|
|
width: 512px;
|
|
height: 512px;
|
|
border: 1px solid black;
|
|
background-color: red;
|
|
}
|
|
</style>
|
|
<script src="../lib/OpenLayers.js"></script>
|
|
<script type="text/javascript">
|
|
<!--
|
|
var lon = 5;
|
|
var lat = 40;
|
|
var zoom = 5;
|
|
var map, layer;
|
|
|
|
function init(){
|
|
map = new OpenLayers.Map( $('map') );
|
|
gmap = new OpenLayers.Layer.Google( "Google" );
|
|
map.addLayer(gmap);
|
|
|
|
markers = new OpenLayers.Layer.Markers("markers");
|
|
map.addLayer(markers);
|
|
|
|
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
|
|
map.addControl( new OpenLayers.Control.LayerSwitcher() );
|
|
}
|
|
|
|
function add() {
|
|
var icon = new OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png',new OpenLayers.Size(10,17));
|
|
marker = new OpenLayers.Marker(new OpenLayers.LonLat(2, 41), icon);
|
|
markers.addMarker(marker);
|
|
}
|
|
|
|
function remove() {
|
|
markers.removeMarker(marker);
|
|
}
|
|
|
|
// -->
|
|
|
|
</script>
|
|
</head>
|
|
<body onload="init()">
|
|
<h1>OpenLayers Example</h1>
|
|
<div id="map"></div>
|
|
<div style="background-color:green" onclick="add()"> click to add the marker to the map</div>
|
|
<div style="background-color:red" onclick="remove()"> click to remove the marker from the map</div>
|
|
</body>
|
|
</html>
|