Updated java script for easier transition to new OpenLayer versions.
This commit is contained in:
parent
46ecb92d5c
commit
4c02b4c2d8
Notes:
subgit
2018-03-07 17:58:39 +01:00
r472 www/trunk
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/*.kml
|
20
index.html
20
index.html
@ -6,6 +6,26 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<style type="text/css">
|
||||
.olControlAttribution {
|
||||
position: absolute;
|
||||
font-size: 10px;
|
||||
text-align: left;
|
||||
color: #eeeeee;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right:auto !important;
|
||||
background: #130085; /* fallback for IE - IE6 requires background shorthand*/
|
||||
background: rgba(0, 60, 136, 0.3);
|
||||
filter: alpha(opacity=30);
|
||||
font-family: 'Lucida Grande', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;
|
||||
border-radius: 5px 0 0 0;
|
||||
}
|
||||
.olControlAttribution a {
|
||||
color: #eeeeee;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
<style type="text/css">
|
||||
html, body, #map {
|
||||
margin: 0;
|
||||
|
@ -34,8 +34,8 @@ function init(showGoogle, showStations, showQuakes, noFrils) {
|
||||
map = new OpenLayers.Map(
|
||||
'map',
|
||||
{
|
||||
projection: new OpenLayers.Projection("EPSG:900913"),
|
||||
displayProjection: new OpenLayers.Projection("EPSG:4326"),
|
||||
projection: new OpenLayers.Projection('EPSG:900913'),
|
||||
displayProjection: new OpenLayers.Projection('EPSG:4326'),
|
||||
controls: [
|
||||
new OpenLayers.Control.Attribution(),
|
||||
new OpenLayers.Control.KeyboardDefaults(),
|
||||
@ -53,15 +53,16 @@ function init(showGoogle, showStations, showQuakes, noFrils) {
|
||||
map = new OpenLayers.Map(
|
||||
'map',
|
||||
{
|
||||
projection: new OpenLayers.Projection("EPSG:900913"),
|
||||
displayProjection: new OpenLayers.Projection("EPSG:4326"),
|
||||
projection: new OpenLayers.Projection('EPSG:900913'),
|
||||
displayProjection: new OpenLayers.Projection('EPSG:4326'),
|
||||
controls: [
|
||||
new OpenLayers.Control.Attribution(),
|
||||
new OpenLayers.Control.KeyboardDefaults(),
|
||||
new OpenLayers.Control.Navigation(),
|
||||
new OpenLayers.Control.Permalink({anchor: true}),
|
||||
new OpenLayers.Control.ScaleLine({geodesic: true})
|
||||
]
|
||||
],
|
||||
zoom: 9
|
||||
}
|
||||
);
|
||||
};
|
||||
@ -76,15 +77,14 @@ function init(showGoogle, showStations, showQuakes, noFrils) {
|
||||
"http://c.tile.openstreetmap.de/tiles/osmde/${z}/${x}/${y}.png"
|
||||
],
|
||||
{
|
||||
attribution: 'Geobasisdaten: Copyright © 2013 <a href="http://www.openstreetmap.org/">OpenStreetMap</a> und Mitwirkende <br />' +
|
||||
attribution: 'Geobasisdaten: Copyright © 2013 <a href="http://www.openstreetmap.org/">OpenStreetMap</a> und Mitwirkende;' +
|
||||
'Lizenz: <a href="http://creativecommons.org/licenses/by-sa/2.0/">Creative Commons BY-SA 2.0.</a>'
|
||||
}
|
||||
);
|
||||
var osm_map_layer = new OpenLayers.Layer.OSM(
|
||||
'OpenStreetMap (Standard)');
|
||||
var osm_map_layer = new OpenLayers.Layer.OSM('OpenStreetMap (Standard)');
|
||||
map.addLayers([
|
||||
osmde_map_layer,
|
||||
osm_map_layer
|
||||
osm_map_layer,
|
||||
osmde_map_layer
|
||||
]);
|
||||
|
||||
// Google Maps
|
||||
@ -123,12 +123,20 @@ function init(showGoogle, showStations, showQuakes, noFrils) {
|
||||
fillColor: '${pntcolor}', fillOpacity: 0.2,
|
||||
strokeColor: '${pntcolor}', strokeWidth: 2,
|
||||
pointRadius: '${pntsize}'
|
||||
},
|
||||
{
|
||||
context: {
|
||||
pntcolor: function(feature){
|
||||
return feature.data.pntcolor.value;
|
||||
},
|
||||
pntsize: function(feature){
|
||||
return feature.data.pntsize.value;
|
||||
}
|
||||
}
|
||||
});
|
||||
var quake_style_select = new OpenLayers.Style({
|
||||
fillColor: '${pntcolor}', fillOpacity: 0.8,
|
||||
strokeColor: '${pntcolor}', strokeWidth: 2,
|
||||
pointRadius: '${pntsize}'
|
||||
});
|
||||
var quake_style_select = quake_style_default.clone();
|
||||
quake_style_select.defaultStyle.fillOpacity = 0.8;
|
||||
|
||||
var quake_style_map = new OpenLayers.StyleMap({
|
||||
'default': quake_style_default,
|
||||
'select': quake_style_select
|
||||
@ -155,25 +163,25 @@ function init(showGoogle, showStations, showQuakes, noFrils) {
|
||||
if (feature.attributes.count) {
|
||||
var c = feature.attributes.count;
|
||||
for (var i=0; i<feature.cluster.length; i++){
|
||||
c = c + feature.cluster[i].attributes.extrastation * 1.0;
|
||||
c = c + feature.cluster[i].data.extrastation.value * 1.0;
|
||||
}
|
||||
return c + ' ' + OpenLayers.i18n('stations');
|
||||
} else {
|
||||
return feature.attributes.name;
|
||||
return feature.data.name;
|
||||
}
|
||||
},
|
||||
tcolor: function(feature){
|
||||
if (feature.attributes.count) {
|
||||
return 'black';
|
||||
} else {
|
||||
return feature.attributes.tcolor;
|
||||
return feature.data.tcolor.value;
|
||||
}
|
||||
},
|
||||
pntsize: function(feature){
|
||||
if (feature.attributes.count) {
|
||||
return Math.min(feature.attributes.count * 2.0 + 6.0, 12);
|
||||
} else {
|
||||
return feature.attributes.pntsize;
|
||||
return feature.data.pntsize.value;
|
||||
}
|
||||
},
|
||||
pntsymbol: function(feature){
|
||||
@ -193,6 +201,19 @@ function init(showGoogle, showStations, showQuakes, noFrils) {
|
||||
});
|
||||
stations_layer.styleMap = station_style_map;
|
||||
|
||||
// Set initial view
|
||||
if (!map.getCenter()) {
|
||||
map.setCenter(new OpenLayers.LonLat(7.5, 51.8).transform('EPSG:4326','EPSG:900913'), 9);
|
||||
}
|
||||
/* if (!map.getZoom()) {
|
||||
map.zoomTo(9);
|
||||
} */
|
||||
|
||||
// Enable animated zoom
|
||||
for (var i=map.layers.length-1; i>=0; --i) {
|
||||
map.layers[i].animationEnabled = true;
|
||||
}
|
||||
|
||||
// Show description
|
||||
select = new OpenLayers.Control.SelectFeature([quakes_layer, stations_layer]);
|
||||
map.addControl(select);
|
||||
@ -201,13 +222,6 @@ function init(showGoogle, showStations, showQuakes, noFrils) {
|
||||
// Add graticule
|
||||
map.addControl(new OpenLayers.Control.Graticule({layerName: OpenLayers.i18n("Grid"), visible: false}));
|
||||
|
||||
// Set initial view
|
||||
if (!map.getCenter()) {
|
||||
map.setCenter(new OpenLayers.LonLat(800500, 6780000),0);
|
||||
}
|
||||
if (!map.getZoom()) {
|
||||
map.zoomTo(9);
|
||||
}
|
||||
}
|
||||
|
||||
/* Function to load KML file */
|
||||
|
Loading…
x
Reference in New Issue
Block a user