forked from geoffmcl/map-test2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tooltip2.html
74 lines (70 loc) · 2.4 KB
/
tooltip2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE HTML>
<html>
<head>
<title>tooltip2 openLayers demo</title>
<style type="text/css">
html, body, #basicMap {
margin: 0;
width: 100%;
height: 100%;
}
</style>
<script src="js/OpenLayers.js"></script>
<script src="js/label.js"></script>
<script>
var map, mapnik, fromProjection, toProjection, position;
var makerLayer, icon;
function init(lat,lon,zoom) {
map = new OpenLayers.Map("basicMap", {
projection: new OpenLayers.Projection("EPSG:3857"),
// this sets wgs84/4326 as default for display coords
displayProjection: new OpenLayers.Projection("EPSG:4326")
});
mapnik = new OpenLayers.Layer.OSM();
fromProjection = new OpenLayers.Projection("EPSG:4326"); // Transform from WGS 1984
toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
position = new OpenLayers.LonLat(lon,lat).transform( fromProjection, toProjection);
map.addLayer(mapnik);
map.addControl(new OpenLayers.Control.Permalink('permalink'));
map.addControl(new OpenLayers.Control.MousePosition());
markerLayer = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markerLayer);
//markers.addMarker(new OpenLayers.Marker(position));
icon = new OpenLayers.Icon('data/img/HP.gif');
var ttTxt = " Helipad H2 lat="+lat+", lon="+lon+", alt=??? ";
var marker = new OpenLayers.Marker.Label(position, icon.clone(), ttTxt ,{mouseOver:true});
markerLayer.addMarker(marker);
map.setCenter(position, zoom );
}
</script>
<style>
.olMarkerLabel {
font-size: small;
color: black;
background-color: #FFFFCC;
width: 150px;
padding: 1px;
border: 1px black solid;
z-index: 1000;
}
</style>
</head>
<body>
<div id="basicMap"></div>
<script type="text/javascript" defer="defer">
function gup2( name, def ) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return def;
return results[1];
}
var lat = gup2('lat',52.52);
var lon = gup2('lon',13.41);
var zoom = gup2('zoom',15);
init(lat,lon,zoom);
</script>
</body>
</html>