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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers Graticule Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
#map {
width: 600px;
height: 300px;
border: 1px solid black;
float:left;
}
#map2 {
width: 400px;
height: 400px;
border: 1px solid black;
float:left;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script src="http://svn.osgeo.org/metacrs/proj4js/trunk/lib/proj4js-compressed.js"></script>
<script type="text/javascript">
Proj4js.defs["EPSG:42304"]="+title=Atlas of Canada, LCC +proj=lcc +lat_1=49 +lat_2=77 +lat_0=49 +lon_0=-95 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs";
var graticuleCtl1, graticuleCtl2;
var map1, map2;
function init(){
initLonLat();
initProjected();
}
function initLonLat(){
graticuleCtl1 = new OpenLayers.Control.Graticule({
numPoints: 2,
labelled: true
});
map1 = new OpenLayers.Map('map', {
controls: [
graticuleCtl1,
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.Navigation()
]
});
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{layers: 'basic'}, {wrapDateLine: true} );
map1.addLayers([ol_wms]);
if (!map1.getCenter()) map1.zoomToMaxExtent();
};
function initProjected(){
var extent = new OpenLayers.Bounds(-2200000,-712631,3072800,3840000);
graticuleCtl2 = new OpenLayers.Control.Graticule({
labelled: true,
targetSize: 200
});
var mapOptions = {
controls: [
graticuleCtl2,
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.Navigation()
],
//scales: tempScales,
maxExtent: extent,
maxResolution: 50000,
units: 'm',
projection: 'EPSG:42304'
};
map2 = new OpenLayers.Map('map2', mapOptions);
var dm_wms = new OpenLayers.Layer.WMS( "DM Solutions Demo",
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap", {
layers: "bathymetry",
format: "image/png"
},{
singleTile: true
});
map2.addLayers([dm_wms]);
if (!map2.getCenter()) map2.zoomToExtent(extent);
}
</script>
</head>
<body onload="init()">
<h1 id="title">Graticule Example</h1>
<div id="tags">
graticule, grid, projection, proj4js, reproject, transform
</div>
<p id="shortdesc">
Adds a Graticule control to the map to display a grid of
latitude and longitude.
</p>
<div id="map" class="smallmap"></div>
<div id="map2" class="smallmap"></div>
<div id="docs"></div>
<br style="clear:both" />
<ul>
<li><a href="#"
onclick="graticuleCtl1.activate(); graticuleCtl2.activate(); return false;">Activate graticule controls</a></li>
<li><a href="#"
onclick="graticuleCtl1.deactivate(); graticuleCtl2.deactivate(); return false;">Deactivate graticule controls</a></li>
</ul>
</body>
</html>
|