-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplanetmap.js
More file actions
291 lines (270 loc) · 9.87 KB
/
Copy pathplanetmap.js
File metadata and controls
291 lines (270 loc) · 9.87 KB
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
var map;
var GlobalMOLARGB;
var GlobalTHEMISIRday;
var GaleCTXWms;
var GaleHRSCWms;
var fake;
var vector_layer;
var vector_layer2;
var vector_layer3;
var vector_layer4;
var delta = 5;
// OpenLayers
OpenLayers.Util.VincentyConstants={a:3396190,b:3396190,f:0}
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 2;
OpenLayers.Util.onImageLoadErrorColor = "transparent";
OpenLayers.ImgPath = "js/OpenLayers/img/"
// OpenLayers.Projection.addTransform(
// 'EPSG:4326',
// 'PS:1',
// OpenLayers.Projection.nullTransform);
// OpenLayers.Projection.addTransform(
// 'PS:1',
// 'EPSG:4326',
// OpenLayers.Projection.nullTransform);
OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';
var maxextent = new OpenLayers.Bounds(-180,-90,180,90);
//
function createParam(key)
{
var value = urlparams[key];
return key + "=" + value;
}
function setUrlHash()
{
var hashvalue = createParam('region');
hashvalue += "&" + createParam("productid");
hashvalue += "&" + createParam('lat');
hashvalue += "&" + createParam('lon');
hashvalue += "&" + createParam('zoomlevel');
location.hash = hashvalue;
}
function showAvailableFootprints(westernlon, easternlon, minlat, maxlat)
{
getODEfootprints('CRISM footprints',westernlon,easternlon,minlat,maxlat);
map.addLayers([footprints]);
map.zoomToExtent(footprints.getDataExtent());
}
function liesInArea(jsonobj, lonlat)
{
if (lonlat.lon >= jsonobj['westernlon'])
if (lonlat.lon <= jsonobj['easternlon'])
if (lonlat.lat >= jsonobj['minlat'])
if (lonlat.lat <= jsonobj['maxlat'])
return true;
return false;
}
function liesInRegion(region, lonlat)
{
return liesInArea(regions[region], lonlat);
}
function liesInProduct(productid, lonlat)
{
return liesInArea(mrdr[productid], lonlat);
}
function getRegion(lonlat)
{
for (region in regions)
{
if (liesInRegion(region, lonlat))
{
return region;
}
}
return "";
}
function getProduct(lonlat)
{
for (productid in mrdr)
{
if (liesInProduct(productid, lonlat))
{
return productid;
}
}
return "";
}
function initmap()
{
map = new OpenLayers.Map( 'map' , {
controls: [
new OpenLayers.Control.Navigation({
defaultDblClick: function(event) {
map.zoomIn();
urlparams['zoomlevel'] = map.getZoom();
var productid = urlparams['productid'];
if (productid != "")
{
loadmrdr(productid);
}
else
{
setUrlHash();
if (map.getZoom() == 5 || map.getZoom() == 6)
{
var bounds = map.getExtent();
showAvailableFootprints(bounds.left, bounds.right, bounds.bottom, bounds.top);
}
}
}
}),
new OpenLayers.Control.PanZoomBar(),
//new OpenLayers.Control.LayerSwitcher({'ascending':false}),
//new OpenLayers.Control.Permalink(),
//new OpenLayers.Control.ScaleLine(),
//new OpenLayers.Control.Permalink('permalink'),
new OpenLayers.Control.MousePosition()
//new OpenLayers.Control.OverviewMap(),
//new OpenLayers.Control.KeyboardDefaults()
],
numZoomLevels: 20, // How can you set the max zoomlevels to HiRISE max?
projection: 'PS:1',
displayProjection: new OpenLayers.Projection("PS:1"),
units: 'degrees',
maxExtent: maxextent});
map.addControl(new OpenLayers.Control.ScaleLine({geodesic: true}));
// A fake base layer
var baseLayerOptions = {
isBaseLayer: true,
displayInLayerSwitcher: false
};
fake = new OpenLayers.Layer('fake', baseLayerOptions);
GlobalMOLARGB = new OpenLayers.Layer.MapServer("MOLA RGB",
planetserver_ms_wms,
{ map: "mola.map", layers: 'molargb', projection: 'PS:1'},
{isBaseLayer: false, transitionEffect: 'resize', wrapDateLine: true});
GlobalTHEMISIRday = new OpenLayers.Layer.MapServer("THEMIS IR day",
planetserver_ms_wms,
{ map: "themisirday.map", layers: 'themisirday', projection: 'PS:2?0', transparent: 'true'},
{isBaseLayer: false, opacity: 0.5, transitionEffect: 'resize', wrapDateLine: true});
// ATTEMPTS to get http://commondatastorage.googleapis.com/ctx_mosaic_1/ctx_mosaic_1.kml
// var kmlctx = new OpenLayers.Layer.TileCache("CTX Mosaic", {
// projection: map.displayProjection,
// strategies: [new OpenLayers.Strategy.Refresh()],
// protocol: new OpenLayers.Protocol.HTTP({
// url: "http://commondatastorage.googleapis.com/ctx_mosaic_1/ctx_mosaic_1.kml",
// format: new OpenLayers.Format.KML({
// extractStyles: true,
// extractAttributes: true,
// maxDepth: 4
// })
// })
// });
// kmlctx.setVisibility(true);
// var kmlctx = new OpenLayers.Layer.TileCache("CTX Mosaic",{
// "projection": map.displayProjection,
// "strategies": [new OpenLayers.Strategy.Refresh()],
// "protocol": new OpenLayers.Protocol.HTTP({
// "url": "http://commondatastorage.googleapis.com/ctx_mosaic_1/ctx_mosaic_1.kml",
// "format": new OpenLayers.Format.KML({
// "extractStyles": true,
// "extractAttributes": true
// })
// })
// });
map.addLayers([fake, GlobalMOLARGB, GlobalTHEMISIRday]);//, GaleHRSCWms]);//, GaleCTXWms]);
map.zoomTo(3);
}
function initpanels()
{
var container = document.getElementById("panel");
var panel = new OpenLayers.Control.Panel({ defaultControl: featureInfo, div: container });
var container2 = document.getElementById("panel2");
var panel2 = new OpenLayers.Control.Panel({ div: container2 });
var container3 = document.getElementById("panel3");
var panel3 = new OpenLayers.Control.Panel({ div: container3 });
panel.addControls([
featureInfo,
featureInfo1,
featureInfo2,
featureInfo3,
featureInfo4,
zoomBox,
new OpenLayers.Control.ZoomBox({title:"Zoom out box", displayClass: 'olControlZoomOutBox', out: true}),
new OpenLayers.Control.DragPan({title:'Drag map', displayClass: 'olControlPanMap'}),
zoomToContextExtent,
navHistory.previous,
navHistory.next,
measureControls.line,
measureControls.polygon
]);
panel2.addControls([
toggleBands,
toggleQuery,
toggleSpectrum,
toggleX3d
]);
panel3.addControls([
toggleTutorial,
toggleAbout//,
//permalink
]);
// add the panel to the map
map.addControl(panel);
map.addControl(panel2);
map.addControl(panel3);
}
function initvectors()
{
var my_style = new OpenLayers.StyleMap({
"default": new OpenLayers.Style(
{
fillColor: "${fcolor}"
})
});
var my_style2 = new OpenLayers.StyleMap({
"default": new OpenLayers.Style(
{
fillColor: "#4bb2c5"
})
});
var my_style3 = new OpenLayers.StyleMap({
"default": new OpenLayers.Style(
{
fillColor: "#ee9900",
strokeWidth: 2,
strokeColor: "#ee9900"
})
});
// Create vector layers to record clicks
vector_layer = new OpenLayers.Layer.Vector("Series", {
styleMap: my_style,
rendererOptions: { zIndexing: true, extractAttributes: true },
displayInLayerSwitcher: false
});
vector_layer2 = new OpenLayers.Layer.Vector("Spectral ratio", {
styleMap: my_style2,
rendererOptions: { zIndexing: true },
displayInLayerSwitcher: false
});
vector_layer3 = new OpenLayers.Layer.Vector("Elevation point", {
styleMap: my_style3,
rendererOptions: { zIndexing: true },
displayInLayerSwitcher: false
});
vector_layer4 = new OpenLayers.Layer.Vector("Cross", {
styleMap: my_style2,
rendererOptions: { zIndexing: true },
displayInLayerSwitcher: false
});
// Limit the number of features that can be added to each
vector_layer.events.on({"beforefeatureadded": function() {
var len = vector_layer.features.length;
if (len == nrclicks) vector_layer.removeFeatures(vector_layer.features[0]);
}
});
vector_layer2.events.on({"beforefeatureadded": function() {
if (vector_layer2.features.length == 2) vector_layer2.destroyFeatures();
}
});
vector_layer3.events.on({"beforefeatureadded": function() {
if (vector_layer3.features.length == 3) vector_layer3.destroyFeatures();
}
});
vector_layer4.events.on({"beforefeatureadded": function() {
if (vector_layer4.features.length == 1) vector_layer4.destroyFeatures();
}
});
//Add layers to the map
map.addLayers([vector_layer,vector_layer2,vector_layer3,vector_layer4]);
}