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 118 119 120 121
|
function initGeoportalMap() {
geoportalLoadviewer("GeoportalviewerDiv", "normal");
// if (viewer.getMap().allowedGeoportalLayers) {
viewer.addGeoportalLayer('GEOGRAPHICALGRIDSYSTEMS.MAPS:WMSC', {opacity:1.0});
var nvC= null;
nvC= viewer.getMap().getControlsByClass('OpenLayers.Control.Navigation');
if (nvC.length>0) {
nvC= nvC[0];
nvC.deactivate();
nvC.zoomWheelEnabled= false;
nvC.activate();
}
/* prereglage de la carte */
viewer.openLayersPanel(true);
viewer.setLayersPanelVisibility(true);
viewer.setToolsPanelVisibility(false);
viewer.setInformationPanelVisibility(false);
// voir http://openlayers.org/dev/examples/highlight-feature.html
//Ajout d'une couche KML : au survol => highlight le nom de la commune (NOM)
var s100Style= new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
// fillColor:'#00ff00',
fillOpacity:0
}),
"temporary": new OpenLayers.Style({
fillColor:'#00ff00',
fillOpacity:0.3,
label: "${getINDIC}",
labelAlign: "center",
labelBackgroundColor:'yellow',
labelBorderColor:'black',
labelBorderSize:'1px',
labelPadding: '5px',//'0 10px 10px 0',
fontColor: "blue",
fontWeight: "bold",
fontSize: "12px",
fontFamily: "Arial"
},{
context:{
getINDIC: function(f) {
return f.attributes['NOM'].value + "\u000A" + f.attributes['NOMBRE'].value +" cartes postales";
}
}
}),
"select": new OpenLayers.Style({
fillColor:'#ff0000',
fillOpacity:0.5
})
});
function OuvrCP(f) {
if (f) {
var nom=f.attributes['NOM'].value;
var codeInsee=f.attributes['CODEINSEE'].value;
var nbCarte=f.attributes['NOMBRE'].value;
var hrefe="../aviewer/"+codeInsee+"/index.html";
var entete=nom + " : " +nbCarte +" cartes postales à consulter";
hs.htmlExpand(null, { src: hrefe, headingText: entete, objectType: 'iframe', height: 530, width: 800 } );
this.unselect(f);
};
}
var s100= viewer.getMap().addLayer("KML","communes","./kml/commune.kml",
{ projection:OpenLayers.Projection.CRS84,//always set projection when setting maxExtent
// don't give maxExtent, let the API compute it ...
minZoomLevel: 7,
maxZoomLevel:10,
panMapIfOutOfView:false,
preFeatureInsert: Geoportal.Popup.setPointerCursorForFeature,
styleMap:s100Style,
visibility: true
},
{
formatOptions:{
extractStyles:false // désactivation des styles
},
preventDefaultBehavior:true // pas de contrôleur Select
});
//au survol => highlight sur le style "temporary" :
var hoverCtrlOpts= OpenLayers.Util.extend( viewer.getMap().getPopupDefaults('KML'), {
hover:true,
highlightOnly: true,
renderIntent: "temporary"
});
// var hoverCtrl= new OpenLayers.Control.SelectFeature([regs, deps], hoverCtrlOpts);
var hoverCtrl= new OpenLayers.Control.SelectFeature([s100], hoverCtrlOpts);
viewer.getMap().addControl(hoverCtrl);
viewer.getMap().events.on({
"changelayer":Geoportal.Map.onVisibilityChange,
scope:hoverCtrl});
//au clic => zoom sur l'emprise de l'objet
var clickCtrlOpts= OpenLayers.Util.extend( viewer.getMap().getPopupDefaults('KML'), {
onSelect: OuvrCP
});
var clickCtrl= new OpenLayers.Control.SelectFeature([s100], clickCtrlOpts);
viewer.getMap().addControl(clickCtrl);
viewer.getMap().events.on({
"changelayer":Geoportal.Map.onVisibilityChange,
scope:clickCtrl});
viewer.getMap().addLayer("KML","Haut-Lignon","./kml/0743.kml", {visibility: true,
opacity:1,
minZoomLevel:7,
maxZoomLevel:12
},
{ hover:false,
onSelect: function(f) {}}// ne rien faire
);
viewer.getMap().setCenterAtLonLat(4.3231201,45.0657615, 10);
} |
Partager