/* * Copyright (c) 2008-2012 Institut National de l'information Geographique et forestiere France, released under the * BSD license. */ /** * Property: viewer * {} the viewer global instance. */ viewer= null; var jeton = null; /** * Function: initMap * Load the application. Called when all information have been loaded by * (). */ function overRiver(feature) { if (feature) { if (!feature.popup) { var ll= feature.geometry.getBounds().getCenterLonLat(); var me= maCarte.getMap().getExtent(); var inView= me.containsLonLat(ll,false); if (!inView) {//hors de la visualisation ll= me.getCenterLonLat(); } feature.popup= new OpenLayers.Popup.FramedCloud( "chicken", ll, null, // on affiche l'attribut 'NAME' dans l'info-bulle : "
" + feature.attributes['NAME']+ "
", null, false); } if (feature.popup) { maCarte.getMap().addPopup(feature.popup,true); } } } function outRiver(feature) { if (feature && feature.popup) { feature.popup.destroy(); feature.popup= null; } } function initMap() { //The api is loaded at this step //L'api est chargée à cette étape // add translations translate(); viewer= new Geoportal.Viewer.Default( "viewerDiv", OpenLayers.Util.extend({ mode:'normal', territory:'FXX', // constrain zooms to RGE scales: minZoomLevel:5, maxZoomLevel:18, // substitution of current default geoportal theme : loadTheme: function() { Geoportal.Util.setTheme('black'); Geoportal.Util.loadCSS(Geoportal._getScriptLocation()+'theme/black/style.css','__GeoportalBlackCss__',''); if (OpenLayers.Util.alphaHack()) { Geoportal.Util.loadCSS(OpenLayers._getScriptLocation()+'theme/black/ie6-style.css','__IE6GeoportalBlackCss__',''); } }, proxy:'HTTP://yaka:8001/proxy.php?url=' }, window.gGEOPORTALRIGHTSMANAGEMENT===undefined? {apiKey:['2585970101035703115']}:gGEOPORTALRIGHTSMANAGEMENT) ); if (!viewer) { OpenLayers.Console.error(OpenLayers.i18n('new.instance.failed')); return; } // BD ORTHO: viewer.addGeoportalLayers([ 'ORTHOIMAGERY.ORTHOPHOTOS:WMSC' ],{ 'ORTHOIMAGERY.ORTHOPHOTOS:WMSC':{ name:'BD ORTHO®', visibility: true, minZoomLevel:9, maxZoomLevel:18 //high resolution ortho-imagery (not everywhere) } }); // BD ADRESSE (kind of): viewer.addGeoportalLayers([ 'GEOGRAPHICALGRIDSYSTEMS.MAPS:WMSC' ],{ 'GEOGRAPHICALGRIDSYSTEMS.MAPS:WMSC':{ name:'BD ADRESSE®', opacity:0.5, minZoomLevel:9, maxZoomLevel:17 } }); // BD TOPO: var lyrs= [ 'ADMINISTRATIVEUNITS.BOUNDARIES:WMSC', 'BUILDINGS.BUILDINGS:WMSC', 'HYDROGRAPHY.HYDROGRAPHY:WMSC', 'TRANSPORTNETWORKS.RAILWAYS:WMSC', 'TRANSPORTNETWORKS.ROADS:WMSC', 'TRANSPORTNETWORKS.RUNWAYS:WMSC', 'UTILITYANDGOVERNMENTALSERVICES.ALL:WMSC' ]; var bdtopoLayers= []; for (var i= 0, l= lyrs.length, n= viewer.getMap().layers.length; in) {//layer added (belongs to contract's key): n= viewer.getMap().layers.length; bdtopoLayers.push(viewer.getMap().layers[n-1]); } } var bdtopo= new Geoportal.Layer.Aggregate( 'BD TOPO®', bdtopoLayers, { visibility: true, minZoomLevel:14, maxZoomLevel:17, description:'BDTOPO.description' } ); viewer.getMap().addLayer(bdtopo); viewer.getMap().setProxyUrl('http://yaka:8001/proxy.php'); // BD PARCELLAIRE: viewer.addGeoportalLayers([ 'CADASTRALPARCELS.PARCELS:WMSC' ],{ 'CADASTRALPARCELS.PARCELS:WMSC':{ name:'BD PARCELLAIRE®', visibility: true, minZoomLevel:16, maxZoomLevel:18 } }); /*viewer.getMap().addLayer( "WMS", 'cantons', "http://yeti/mapguide2010/mapagent/mapagent.fcgi", {//paramètres_du_wms: contient tous les paramètres nécessaires au paramétrage du service WMS layers:'COM_PL_CANTON', format:'image/png', transparent:'true' }, { //options_couche: contient les paramètres pour gérer le comportement de la couche WMS projection:'EPSG:4326', units:'degrees', // maxExtent expressed in EPSG:4326 : maxExtent: new OpenLayers.Bounds(-180,-90,180,90), minZoomLevel: 5, maxZoomLevel:15, opacity:0.4, isBaseLayer: false, visibility: false, // add GetFeatureInfo button : } );*/ viewer.getMap().addLayer( "WMS", 'cantons', "http://yaka:8080/cgi-bin/mapserv.exe?map=c:/ms4w/apps/WMS.map", {//paramètres_du_wms: contient tous les paramètres nécessaires au paramétrage du service WMS layers:'wgs84', format:'image/png', transparent:'false' }, { //options_couche: contient les paramètres pour gérer le comportement de la couche WMS projection:'EPSG:4326', units:'degrees', // maxExtent expressed in EPSG:4326 : maxExtent: new OpenLayers.Bounds(-180,-90,180,90), minZoomLevel: 5, maxZoomLevel:15, opacity:0.4, isBaseLayer: false, visibility: false, originators:[ { logo:'meddtl', pictureUrl:'http://www.developpement-durable.gouv.fr/squelettes/img/logo.gif', url:'http://www.cg66.fr/' }, { logo:'irstea', picturelUrl:'http://www.irstea.fr/sites/default/files/logo_entete.png', url:'http://www.irstea.fr/' } ] // add GetFeatureInfo button : } ); /* viewer.getMap().addLayer( "WFS", 'cantons_wfs', "http://yaka:8080/cgi-bin/mapserv.exe?map=c:/ms4w/apps/WFS.map", { featureType: "poly2154", geometryName: "Shape" }, { projection: 'EPSG:4326', units:'degrees', // maxExtent est exprimée en EPSG:4326 : maxExtent: new OpenLayers.Bounds(-180,-90,180,90), minZoomLevel:10, maxZoomLevel:15, isBaseLayer: false, visibility: false, originators: [ { logo:'sandre', pictureUrl: 'logo_sandre.gif', url: 'http://sandre.eaufrance.fr' } ], extractAttributes:true, styleMap:rwbodyStyle, onSelect: overRiver, onUnselect: outRiver, hover: true } );*/ // BD TOPO (BD NYME), BD ADRESSE (search engines): var tbx= viewer.getMap().getControlsByClass('Geoportal.Control.ToolBox')[0]; var searchbar= new Geoportal.Control.SearchToolbar( { div: OpenLayers.Util.getElement(tbx.id+'_search'), geonamesOptions: { setZoom: Geoportal.Control.LocationUtilityService.GeoNames.setZoomForBDNyme, layerOptions: { name: 'TOPONYMS.ALL:OPENLS', maximumResponses:100, formatOptions: { version:'1.0' } } }, geocodeOptions: { layerOptions: { name: 'ADDRESSES.CROSSINGS:OPENLS', maximumResponses:100, formatOptions: { version:'1.0' } }, matchTypes: [ {re:/city/i, src:Geoportal.Util.getImagesLocation()+'OLScity.gif'}, {re:/street$/i, src:Geoportal.Util.getImagesLocation()+'OLSstreet.gif'}, {re:/number/i, src:Geoportal.Util.getImagesLocation()+'OLSstreetnumber.gif'}, {re:/enhanced/i, src:Geoportal.Util.getImagesLocation()+'OLSstreetenhanced.gif'}, {re:null, src:Geoportal.Util.getImagesLocation()+'OLSstreet.gif'} ] } } ); viewer.getMap().addControl(searchbar); // add print control: var nv= viewer.getMap().getControlsByClass('Geoportal.Control.NavToolbar')[0]; nv.addControls([new Geoportal.Control.PrintMap()]); var lonlat= new OpenLayers.LonLat(2,42); viewer.getMap().setCenter(lonlat,8); viewer.getMap().displayProjection = new OpenLayers.Projection("EPSG:4326"); //alert(viewer.getMap().getProjection()); jeton=Geoportal.GeoRMHandler.Updater('2585970101035703115','http://jeton-api.ign.fr/',60).getToken(); // cache la patience - hide loading image viewer.div.style[OpenLayers.String.camelize('background-image')]= 'none'; } /** * Function: loadAPI * Load the configuration related with the API keys. * Called on "onload" event. * Call () function to load the interface. */ function loadAPI() { // wait for all classes to be loaded // on attend que les classes soient chargées if (checkApiLoading('loadAPI();',['OpenLayers','Geoportal','Geoportal.Viewer','Geoportal.Viewer.Default'])===false) { return; } // load API keys configuration, then load the interface // on charge la configuration de la clef API, puis on charge l'application Geoportal.GeoRMHandler.getConfig(['2585970101035703115'], null,"http://jeton-api.ign.fr/", { onContractsComplete: initMap }); } // assign callback when "onload" event is fired // assignation de la fonction à appeler lors de la levée de l'évènement // "onload" window.onload= loadAPI;