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
|
<!DOCTYPE html>
<html>
<head>
<title>POI survol</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
.gpControlInformation {
display: none !important;
}
</style>
</head>
<body>
<h1>Probleme de gestion du zoom et du click voir <a href="http://www.developpez.net/forums/d1212366/applications/sig-systeme-dinformation-geographique/ign-api-geoportail/reactivation-couche-minzoomlevel-maxzoomlevel/" target="_blank">forum</a></h1>
<div id="GeoportalviewerDiv" style="width:800px; height:600px;"></div>
<script type="text/javascript"
src="http://api.ign.fr/geoportail/api/js/latest/lib/geoportal/lib/Geoportal.js"></script>
<script type="text/javascript">
var viewer= null;
function initGeoportalMap() {
viewer= new Geoportal.Viewer.Default(
"GeoportalviewerDiv",
OpenLayers.Util.extend({
minZoomLevel:10,
maxZoomLevel:17,
},gGEOPORTALRIGHTSMANAGEMENT));
viewer.addGeoportalLayer('GEOGRAPHICALGRIDSYSTEMS.MAPS:WMSC',{visibility: true,opacity:1.0});
viewer.getMap().setCenterAtLonLat(4.3231201,45.0657615, 10);
var affich= function(feature) {
if (feature) {
alert(feature.data.description);
}
this.unselect(feature);
};
var clicCommune= function(f) {
var zoom= viewer.getMap().getZoom();
if (zoom == 10) {
viewer.getMap().zoomTo(14);
} else {
viewer.getMap().zoomTo(zoom + 1);
}
};
var cep= viewer.getMap().addLayer("KML","Les refuges","./POIgite.kml", {
visibility: true,
minZoomLevel:10,
maxZoomLevel:10
},{
onUnselect: function(f) {},
onSelect:affich,
hover:true
});
var clickCtrlOpts = OpenLayers.Util.extend(viewer.getMap().getPopupDefaults('KML'), {
onSelect : clicCommune,
autoActivate : true,
handlersOptions : {
feature : {
stopDown : false //allow pan map when drag in feature
}
}
});
var clickCtrl = new OpenLayers.Control.SelectFeature([cep], clickCtrlOpts);
viewer.getMap().addControl(clickCtrl);
viewer.getMap().events.on({
"changelayer" : Geoportal.Map.onVisibilityChange,
scope : clickCtrl
});
}
//Début Mise à niveau Geoportail version 1.3
if (window.__Geoportal$timer===undefined) {
var __Geoportal$timer= null;
}
function checkApiLoading(retryClbk,clss) {
if (__Geoportal$timer!=null) {
window.clearTimeout(__Geoportal$timer);
__Geoportal$timer= null;
}
var f;
for (var i=0, l= clss.length; i<l; i++) {
try {
f= eval(clss[i]);
} catch (e) {
f= undefined;
}
if (typeof(f)==='undefined') {
__Geoportal$timer= window.setTimeout(retryClbk, 300);
return false;
}
}
return true;
}
function loadAPI() {
// on attend que les classes soient chargées
if (checkApiLoading(loadAPI,['OpenLayers','Geoportal','Geoportal.Viewer','Geoportal.Viewer.Default'])===false) {
return;
}
// on charge la configuration de la clef API, puis on charge
// l'application
Geoportal.GeoRMHandler.getConfig(['CLEF'], null, null, {
onContractsComplete: initGeoportalMap
});
}
window.onload= loadAPI;
</script>
</body>
</html> |
Partager