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
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script
type="text/javascript"
src="http://api.ign.fr/geoportail/api?v=VERSION&key=YOUR_LICENSE&instance=myMap&">
<!--
-->
</script>
<script type="text/javascript">
<!--
function initGeoportalMap() {
// call on body's onLoad
OpenLayers.Control.Click= OpenLayers.Class( OpenLayers.Control, {
defaultHandlerOptions:{
'single': true,
'double': false,
'pixelTolerance': 0,
'stopSingle': false,
'stopDouble': false
},
/**
* Constructor
*/
initialize: function(options) {
OpenLayers.Control.prototype.initialize.apply(this,arguments);
this.handlerOptions= OpenLayers.Util.extend({},this.defaultHandlerOptions);
this.handler= new OpenLayers.Handler.Click(
this, {'click': this.trigger}, this.handlerOptions);
},
/**
* APIMethod: trigger
*/
trigger: function(e) {
var lonlat= this.map.getLonLatFromViewPortPx(e.xy).transform(
this.map.getProjection(), OpenLayers.Projection.CRS84
);
alert("You clicked near " + lonlat.lon + "N, " + lonlat.lat + " E");
}
});
// the map must be created and configured here
geoportalLoadmyMap("layerDiv", "normal" );
myMap.addGeoportalLayers(myMap.allowedGeoportalLayers);
// creating and inserting the new control
var myClick= new OpenLayers.Control.Click();
myMap.getMap().addControl(myClick);
myClick.activate();
}
-->
</script>
</head>
<body>
<div id="layerDiv" style="width:800px;height:600px;"></div>
</body>
</html> |
Partager