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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- coding: utf-8 -->
<head>
<title>affichage pour img</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="cache-control" content="no-cache">
<style type="text/css">
body {
background: #E9E8B7;
margin: 0;
padding: 0;
}
#titre {
background-color:#FFFFFF;
border:1px solid black;
padding:5px;
}
#legende {
background-color:#FFFFFF;
border:1px solid black;
padding:5px;
}
#viewerDiv{
float: left;
marging: 2px;
width:1138px;
height:752px;
background-color:white;
background-image:url(http://api.ign.fr/geoportail/api/js/.../loading.gif);
background-position:center center;
background-repeat:no-repeat;
}
</style>
</head>
<body>
<div id="viewerDiv" >
</div>
<script type="text/javascript"><!--//--><![CDATA[//><!--
var viewer = null;
<?php
if (isset($_GET['ilot']))
{
$ilot = $_GET['ilot'];
}
?>
var numero_ilot = '<?=$ilot;?>';
function initGeoportalMap()
{
var options = {};
options.mode = 'normal';
options.territory = 'FXX';
options.nameInstance = 'viewer';
OpenLayers.Util.extend(options, gGEOPORTALRIGHTSMANAGEMENT || {});
viewer = new Geoportal.Viewer.Default('viewerDiv', options);
affiche();
// On affiche la couche IGN
var layerOption = {};
//layerOption.opacity = 0.4;
//layerOption.visibility = true;
// viewer.addGeoportalLayer('GEOGRAPHICALGRIDSYSTEMS.MAPS', layerOption);
layerOption.opacity = 0.8;
layerOption.visibility = true;
viewer.addGeoportalLayer('ORTHOIMAGERY.ORTHOPHOTOS', layerOption);
// Choix sur les boites à outils et autre zoom
viewer.setLayersPanelVisibility(false); // Boite info couches
viewer.openLayersPanel(false); // Ouverte ou fermée
viewer.setToolsPanelVisibility(false); // Boite à outils zoom
viewer.openToolsPanel(false); // Fermée ou ouverte
viewer.setInformationPanelVisibility(false); // Coordonnées bas de carte
// Centrage de la carte
// viewer.getMap().setCenterAtLonLat(-1.35,46.91,14,false,false);
}
function affiche() {
var symb1= {
'PT' :{fillColor:'#0DF20D', strokeWidth:2},
'PP' :{fillColor:'#008000', strokeWidth:2},
'MAIS' :{fillColor:'#D99226', strokeWidth:2},
'CER' :{fillColor:'#FFFF00', strokeWidth:2},
'AC' :{fillColor:'#800000', strokeWidth:2},
'OLEA' :{fillColor:'#800080', strokeWidth:2},
'AU' :{fillColor:'#C0C0C0', strokeWidth:2},
'PROT' :{fillColor:'#00FFFF', strokeWidth:2},
'GEL' :{fillColor:'#0000FF', strokeWidth:2}
};
var contextMAJ = function(feature) {
return { 'code_MAJ': feature.attributes['code_MAJ'].value };
}
var styles = new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
strokeColor:'#000000',
strokeWidth:2,
fillColor:'#ff0000',
fillOpacity:0.5,
label: "${getNOM}",
labelAlign: "rb",
labelXOffset: '-10',
labelBackgroundColor:'white',
//labelBackgroundOpacity:0.3,
labelBorderColor:'black',
labelBorderSize:'1px',
labelPadding: '3.5px',
fontColor: "red",
fontWeight: "bold",
fontSize: "10px",
fontFamily: "Arial"
},{
context:{
getNOM: function(f) {
return f.attributes['NUM_ILOT'].value;
}
}
}),
"temporary": new OpenLayers.Style({
strokeColor:'#00ff00',
strokeWidth:2,
fillColor:'#00ff00',
fillOpacity:0.5
}),
"select": new OpenLayers.Style({
strokeColor:'#00ff00',
strokeWidth:2,
fillColor:'#0000ff',
fillOpacity:0.5
})
});
styles.addUniqueValueRules('default','code_MAJ',symb1,contextMAJ);
//recuperation du pacage et transformation en nom fichier
<?php
if (isset($_GET['pacage']))
{
$valeur = $_GET['pacage'];
}
// if (isset($_GET['ilot']))
// {
// $ilot = $_GET['ilot'];
// }
?>
var valeur = '<?=$valeur;?>';
// mise en forme de l'adresse du fichier kml
var fichier = 'http://*************/'+valeur;
kmlLayer = viewer.getMap().addLayer(
"KML",
valeur, //nom couche
fichier, //nom fichier
{
styleMap:styles,
visibility: true,
panMapIfOutOfView:false,
originators: [
{
logo:'ISIS',
pictureUrl: 'sourceisis2012.jpg',
}],
eventListeners:{
"loadend":kmlLoadend
},
//minZoomLevel: 8,
//maxZoomLevel: 20
},
{
formatOptions:{
extractStyles:false // d財ctivation des styles
},
}
);
}
function kmlLoadend() {
var liste_ilots='';
var exploitation='';
var titre='';
var legende='';
var PT=0;
var PP=0;
var CER=0;
var AC=0;
var AU=0;
var PROT=0;
var OLEA=0;
var MAIS=0;
var GEL=0;
var surftotale=0;
var surfaceculture="";
//affiche l'ensemble de parcelles
// viewer.getMap().zoomToExtent(kmlLayer.maxExtent);
for (var i= 0, nbF = kmlLayer.features.length; i<nbF; i++) {
if ( ! kmlLayer.features[i].attributes ) {
continue;
}
//pr诡ration affichage entete
if (i==0) {
titre+='Pacage : 0'+kmlLayer.features[0].attributes['PACAGE'].value+'<br />';
}
if (kmlLayer.features[0].attributes['nom']) {
titre+=kmlLayer.features[i].attributes['nom'].value+'<br />';
}
if (kmlLayer.features[0].attributes['lieu_dit']) {
titre += kmlLayer.features[0].attributes['lieu_dit'].value+'<br />';
}
if (kmlLayer.features[0].attributes['commune_2']) {
titre += kmlLayer.features[0].attributes['commune_2'].value+'<br />';
}
// les cl�© ` conserver
var cles = /(NUM_ILOT|SURF_ILOT|PT|PP|CER|MAIS|OLEA|PROT|AU|AC|GEL|code_MAJ)/;
for ( var k in kmlLayer.features[i].attributes ) {
if ( ! cles.test(k) ) {
delete kmlLayer.features[i].attributes[k];
continue;
}
if ( kmlLayer.features[i].attributes[k].value == 0 ) {
delete kmlLayer.features[i].attributes[k];
}
}
//zoom sur ilot de url
if ( kmlLayer.features[i].attributes['NUM_ILOT'].value == numero_ilot ) {
var feature = kmlLayer.features[i];
viewer.getMap().zoomToExtent(feature.geometry.getBounds(), closest=true);
// baisse le niveau de zoom de 1 pour meilleur affichage
var zoom=viewer.getMap().getZoom();
zoom=zoom-2;
viewer.getMap().zoomTo(zoom);
}
}// fin for i
legende+='<font color="#FFFFFF">Culture majoritaire dans l ilot</font><br/><br/>';
legende+='<font color="#0DF20D">Prairie Temporaire : PT</font><br/>';
legende+='<font color="#008000">Prairie Permanente : PP</font><br/>';
legende+='<font color="#FFFF00">Cèréales : CER</font><br/>';
legende+='<font color="#D99226">Mais : MAIS</font><br/>';
legende+='<font color="#00FFFF">Protèagineux : PROT</font><br/>';
legende+='<font color="#800080">Olèagineux : OLEA</font><br/>';
legende+='<font color="#800000">Autres cultures : AC</font><br/>';
legende+='<font color="#C0C0C0">Autres utilisations : AU</font><br/>';
legende+='<font color="##0000FF">Gel</font><br/>';
//document.getElementById('entete').innerHTML = exploitation;
document.getElementById('titre').innerHTML = titre;
}//fin fonction
-->
//--><!]]></script>
<script type="text/javascript" charset="utf-8" src="http://api.ign.fr/geoportail/api/js/latest/Geoportal.js">
<!-- -->
</script>
<script type="text/javascript"><!--//--><![CDATA[//><!--
if (window.__Geoportal$timer===undefined)
{
var __Geoportal$timer= null;
}
function checkApiLoading(retryClbk,clss)
{
if (__Geoportal$timer!=null)
{
//clearTimeout: annule le minuteur "__Geoportal$timer" avant sa fin
window.clearTimeout(__Geoportal$timer);
__Geoportal$timer= null;
}
/**
* Il se peut que l'init soit exécuté avant que l'API ne soit chargée
* Ajout d'un code temporisateur qui attend 300 ms avant de relancer l'init
*/
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
Geoportal.GeoRMHandler.getConfig(['ldskk3wsum4necbitct2tas5'], null, null, {onContractsComplete: initGeoportalMap});
}
//chargement de l'application API
window.onload= loadAPI;
//--><!]]></script>
<div id='titre' style='display:true; position:absolute; left:5px; top:5px'></div>
<div id='legende' style='display:true; position:absolute; left:5px; top:518px'>
<font color="#000000">Cultures majoritaires</font><br/><br/>
<font color="#0DF20D">█ Prairie Temporaire</font><br/>
<font color="#008000">█ Prairie Permanente</font><br/>
<font color="#FFFF00">█ Céréales</font><br/>
<font color="#D99226">█ Mais</font><br/>
<font color="#00FFFF">█ Protéagineux</font><br/>
<font color="#800080">█ Oléagineux</font><br/>
<font color="#800000">█ Autres cultures</font><br/>
<font color="#C0C0C0">█ Autres utilisations</font><br/>
<font color="#0000FF">█ Gel</font><br/>
</div>
</body>
</html> |
Partager