-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmapComparing.html
251 lines (222 loc) · 9.05 KB
/
mapComparing.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!doctype html>
<html>
<head>
<title>RHoK - Spatial Truth - Vicmap comparison</title>
<script type="text/javascript" src="http://svn.osgeo.org/metacrs/proj4js/trunk/lib/proj4js-compressed.js"></script>
<script type="text/javascript" src="http://spatialreference.org/ref/epsg/31467/proj4js/"></script>
<script src="js/OpenLayers-2.12/OpenLayers.js" type="text/javascript"></script>
<script src="http://maps.google.com/maps/api/js?v=3&sensor=false"></script>
<script src="js/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="http://www.patrick-wied.at/static/heatmapjs/src/heatmap.js" type="text/javascript"></script>
<script src="http://www.patrick-wied.at/static/heatmapjs/src/heatmap-openlayers.js" type="text/javascript"></script>
<script>
Proj4js.defs["EPSG:3111"] = "+proj=lcc +lat_1=-36 +lat_2=-38 +lat_0=-37 +lon_0=145 +x_0=2500000 +y_0=2500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
</script>
<script type="text/javascript">
var maps={};
var layers={};
$(function(){
maps.vicmap = setupVicMap('map1');
maps.google = setupGoogleMap('map2');
maps.bing = setupBing('map3');
maps.osm = setupOsm('map4');
for(i in maps){
var theMap = maps[i];
theMap.events.register('move', theMap, function(evt){
onMove(evt.object);
});
}
var loc = new OpenLayers.LonLat(144.9667,-37.7833) ;
centreAll(loc,16);
setDummyData();
checkLocation();
});
var marker;
function checkLocation(){
if (!marker){
marker = new google.maps.Marker({
title:"I am here!"
});
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position){
var latlon = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
map.panTo(latlon);
//set marker
marker.setPosition(latlon);
marker.setMap(map);
$('#locator').show();
},function(e){
//failed to get postion
marker.setMap(null);
});
}
}
var moving = false;
function onMove(map){
if (moving) {
return;
}
var loc = map.getCenter();
var loc_ = loc.clone();
loc_.transform(
map.getProjectionObject(),
new OpenLayers.Projection("EPSG:4326")
)
var zoom = map.getZoom();
if( map.zoomChange){
zoom = zoom - map.zoomChange;
}
centreAll (loc_,zoom);
}
function centreAll(loc,zoom){
moving = true;
for(i in maps){
var theMap = maps[i];
centre(theMap,loc,zoom);
}
moving = false;
}
function setupGoogleMap(divName){
var map = new OpenLayers.Map(divName, {allOverlays: false});
map.addControl(new OpenLayers.Control.LayerSwitcher());
var gsat = new OpenLayers.Layer.Google(
"Google Satellite",
{type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22}
);
var gphy = new OpenLayers.Layer.Google(
"Google Physical",
{type: google.maps.MapTypeId.TERRAIN, visibility: false}
);
var gmap = new OpenLayers.Layer.Google(
"Google Streets", // the default
{numZoomLevels: 20, visibility: false}
);
var ghyb = new OpenLayers.Layer.Google(
"Google Hybrid",
{type: google.maps.MapTypeId.HYBRID, numZoomLevels: 22, visibility: false}
);
map.addLayers([ gmap, gsat, gphy, ghyb]);
return map;
}
function setupVicMap(divName){
var vic_p1 = new OpenLayers.Projection("EPSG:3111");
var vic_p2 = new OpenLayers.Projection("EPSG:4326");
var vic_extent = new OpenLayers.Bounds(140, -39.5, 151, -34).transform(vic_p2,vic_p1);
var vic_options = {
units : "meters",
projection :vic_p1 ,
displayProjection: vic_p2,
//maxExtent: vic_extent ,
tileSize: new OpenLayers.Size(512,512),
resolutions : [2116.670900008467, 1058.3354500042335, 529.1677250021168, 264.5838625010584, 132.2919312505292, 66.1459656252646, 26.458386250105836, 13.229193125052918, 6.614596562526459, 2.6458386250105836, 1.3229193125052918, 0.6614596562526459, 0.33072982812632296, 0.21166709000084669],
maxExtent : new OpenLayers.Bounds(1786000, 1997264.499195665, 3953471.00160867, 3081000)
};
var vicmap = new OpenLayers.Layer.WMS( "VicMap",
"http://116.240.195.134/vicmapapi/map/wms",
{
layers: 'CARTOGRAPHICAL',
format: 'image/png'
});
var map = new OpenLayers.Map(divName,vic_options);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addLayers([vicmap]);
map.zoomChange = -6;
return map;
}
function setupOsm(mapDiv){
var map = new OpenLayers.Map(mapDiv);
var osm = new OpenLayers.Layer.OSM();
map.addLayers([osm]);
return map;
}
function setupBing(mapDiv){
var apiKey = "AqTGBsziZHIJYYxgivLBf0hVdrAk9mWO5cQcb8Yux8sW5M8c8opEC2lZqKR1ZZXf";
map = new OpenLayers.Map(mapDiv);
map.addControl(new OpenLayers.Control.LayerSwitcher());
var road = new OpenLayers.Layer.Bing({
name: "Road",
key: apiKey,
type: "Road"
});
var hybrid = new OpenLayers.Layer.Bing({
name: "Hybrid",
key: apiKey,
type: "AerialWithLabels"
});
var aerial = new OpenLayers.Layer.Bing({
name: "Aerial",
key: apiKey,
type: "Aerial"
});
map.addLayers([aerial, road, hybrid ]);
map.zoomChange = -1;
return map;
}
function centre(map,loc,zoom){
var loc_=loc.clone();
if ( map.zoomChange ) {
zoom = zoom + map.zoomChange;
}
map.setCenter(loc_.transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
), zoom);
}
function setDummyData(){
layers.fireLayer = new OpenLayers.Layer.Markers( "Fires" );
maps.vicmap.addLayer(layers.fireLayer);
layers.heatmap = new OpenLayers.Layer.Heatmap( "Heatmap Layer", map, layers.fireLayer, {visible: true, radius:50},
{isBaseLayer: false, opacity: 0.3, projection: new OpenLayers.Projection("EPSG:900913")});
maps.google.addLayer(layers.heatmap);
setInterval(addFire,2*1000);
}
var fireData = [];
function addFire(){
var size = new OpenLayers.Size(32,32);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new OpenLayers.Icon('http://images1.wikia.nocookie.net/__cb20110531055851/sims/images/5/54/Fire!.png',
size,offset);
var loc = maps.vicmap.getCenter();
marker = new OpenLayers.Marker(loc,icon.clone());
layers.fireLayer.addMarker(marker);
loc = maps.google.getCenter();
var transformedTestData = {};
fireData.push({
lonlat: loc,
count: 1
});
transformedTestData.data = fireData;
transformedTestData.max=5;
layers.heatmap.setDataSet(transformedTestData);
}
</script>
</head>
<body>
<div id="main" style='height:600px'>
<table style="width:100%;height:100%;">
<tr>
<td colspan="2" style="height:1px;">
</td>
</tr>
<tr>
<td>
<div id="map1" style='height:100%;width:100%;'> </div>
</td>
<td>
<div id="map2" style='height:100%;width:100%;'> </div>
</td>
</tr>
<tr>
<td>
<div id="map3" style='height:100%;width:100%;'> </div>
</td>
<td>
<div id="map4" style='height:100%;width:100%;'> </div>
</td>
</tr>
</table>
</div>
</body>
</html>