directory to deploy when depending on features which use CSS, and make it clear how to override the CSS in OpenLayers, include <link rel> ags in all examples. (Closes #884) git-svn-id: http://svn.openlayers.org/trunk/openlayers@6145 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
55 lines
1.8 KiB
HTML
55 lines
1.8 KiB
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<title>OpenLayers Click Event Example</title>
|
|
|
|
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
|
|
<style type="text/css">
|
|
#map {
|
|
width: 512px;
|
|
height: 512px;
|
|
border: 1px solid black;
|
|
}
|
|
</style>
|
|
<script src="../lib/OpenLayers.js"></script>
|
|
<script type="text/javascript">
|
|
var map;
|
|
function init(){
|
|
map = new OpenLayers.Map('map');
|
|
|
|
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
|
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
|
|
|
|
var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
|
|
"http://t1.hypercube.telascience.org/cgi-bin/landsat7",
|
|
{layers: "landsat7"});
|
|
|
|
jpl_wms.setVisibility(false);
|
|
|
|
map.addLayers([ol_wms, jpl_wms]);
|
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
|
// map.setCenter(new OpenLayers.LonLat(0, 0), 0);
|
|
map.zoomToMaxExtent();
|
|
map.events.register("click", map, function(e) {
|
|
var lonlat = map.getLonLatFromViewPortPx(e.xy);
|
|
alert("You clicked near " + lonlat.lat + " N, " +
|
|
+ lonlat.lon + " E");
|
|
});
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="init()">
|
|
<h1 id="title">Click Event Example</h1>
|
|
|
|
<div id="tags">
|
|
</div>
|
|
|
|
<p id="shortdesc">
|
|
This example shows the use of the register and getLonLatFromViewPortPx functions to trigger events on mouse click.
|
|
</p>
|
|
|
|
<div id="map"></div>
|
|
|
|
<div id="docs"></div>
|
|
</body>
|
|
</html>
|