Added event hadler to toggle quake mapkey.

This commit is contained in:
Kasper D. Fischer 2013-02-22 15:04:38 +00:00
parent 8cafc17840
commit 23ea60ba31
Notes: subgit 2018-03-07 17:58:39 +01:00
r476 www/trunk
2 changed files with 38 additions and 26 deletions

View File

@ -4,26 +4,9 @@
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>RUB SeisObs - Station and Seismicity Map</title>
<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>
</head>
<body>
<style type="text/css">
html, body, #map {
margin: 0;
@ -54,9 +37,26 @@
padding: 0px 0px 0px 0px;
}
</style>
</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>
<script type='text/javascript' src='OpenLayers.js'></script>
<script type='text/javascript' src='https://maps.google.com/maps/api/js?sensor=false&amp;v=3.9'></script>
<script type='text/javascript' src='station_map_www.js'></script>
@ -77,9 +77,9 @@
});
OpenLayers.Lang.setCode(document.documentElement.lang);
</script>
<!-- <div id="mapkey">
<div id="mapkey">
<script type='text/javascript'>initKey(true, false, false);</script>
</div> -->
</div>
<div id="map">
<script type='text/javascript'>init(true, true, false, false);</script>
</div>

View File

@ -127,6 +127,7 @@ function init(showGoogle, showStations, showQuakes, noFrils) {
// Show quakes
quakes_layer = loadKML(OpenLayers.i18n("Events"), 'quakes.kml', false, true);
quakes_layer.events.on({'visibilitychanged': toggleQuakesMapkey});
map.addLayer(quakes_layer);
quakes_layer.setVisibility(showQuakes);
@ -295,7 +296,7 @@ function onPopupClose(evt) {
select.unselectAll();
}
/* Function called when clicking on a markger */
/* Function called when clicking on a marker */
function onFeatureSelect(event) {
var feature = event.feature;
// Since KML is user-generated, do naive protection against
@ -337,3 +338,14 @@ function onFeatureUnselect(event) {
delete feature.popup;
}
}
/* Function to activate map legend */
function toggleQuakesMapkey() {
var mapkey_div = document.getElementById('mapkey');
var quakes_visibility = quakes_layer.getVisibility();
if (quakes_visibility) {
mapkey_div.style.display = "block";
} else {
mapkey_div.style.display = "none";
}
}