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
| /*
* Copyright (c) 2008-2011 Institut Geographique National France, released under the
* BSD license.
*/
/**
* Property: key
*
* The API key to use
*/
APIkey= "nf7s3viaoh89yyson4n6h6bn";
// en local : var APIkey= "zj6hm1922y559tdqae87jjzs"
/**
* Property: viewer
* {<Geoportal.Viewer>} the viewer global instance.
*/
viewer= null;
/**
* Function: initMap
* Load the application. Called when all information have been loaded by
* <loadAPI>().
*/
function initMap() {
// ----- Traduction
translate();
// ----- Options
var options= {
mode:'normal',
territory:'FXX',
displayProjection:['IGNF:LAMB93', 'CRS:84'],
proxy:'assets/proxy.php?url='
};
var MailleStyleMap = new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
'strokeColor' : '#ff0000',
'strokeOpacity' : 1,
'strokeWidth' : 1.5,
'fillColor': '#ff0000',
'fillOpacity': 0
}),
"select": new OpenLayers.Style({
'strokeColor' : '#ff0000',
'strokeOpacity' : 1,
'strokeWidth' : 1.5,
'fillColor': '#ff00ff',
'fillOpacity': 0
})
});
viewer= new Geoportal.Viewer.Default('viewerDiv', OpenLayers.Util.extend(
options,
// API keys configuration variable set by <Geoportal.GeoRMHandler.getConfig>
// variable contenant la configuration des clefs API remplie par <Geoportal.GeoRMHandler.getConfig>
window.gGEOPORTALRIGHTSMANAGEMENT===undefined? {'apiKey':APIkey} : gGEOPORTALRIGHTSMANAGEMENT)
);
if (!viewer) {
// problem ...
OpenLayers.Console.error(OpenLayers.i18n('new.instance.failed'));
return;
}
// ----- Layers
viewer.addGeoportalLayers(['ORTHOIMAGERY.ORTHOPHOTOS','GEOGRAPHICALGRIDSYSTEMS.MAPS']);
viewer.getMap().addLayer(
"KML",
'Nombre de Noctuelles',
"./utm_bn_nbnoct2013a.kml",
{
visibility:false
}
);
viewer.getMap().addLayer(
"KML",
'Mailles',
"./utm_bn_2012.kml",
{
visibility:false,
styleMap:MailleStyleMap
},
{
formatOptions:{extractStyles :false}
}
);
viewer.getMap().addLayer(
"KML",
'Lepidopteristes',
"./lepidopterist_201310.kml",
{
visibility:false
}
);
viewer.getMap().addLayer(
"KML",
'Departements BN',
"../KML/dept/dept_bn2.kml",
{
visibility:true
}
);
// ----- Autres
viewer.getMap().setCenterAtLonLat(-0.42,48.955,8);
var tbx= viewer.getMap().getControlsByClass('Geoportal.Control.ToolBox')[0];
var panel= new Geoportal.Control.Panel({
div:OpenLayers.Util.getElement(tbx.id+'_search')//hook/anchor
});
var gazetteer= new Geoportal.Control.LocationUtilityService.GeoNames(
new Geoportal.Layer.OpenLS.Core.LocationUtilityService(
'PositionOfInterest:OPENLS;Geocode',//layer name
{
maximumResponses:100,
formatOptions: {
},
// define your own picto instead of default:
styleMap:new OpenLayers.StyleMap({
"default": new OpenLayers.Style(
OpenLayers.Util.applyDefaults({
externalGraphic:"http://maps.gstatic.com/intl/fr_fr/mapfiles/ms/icons/blue-dot.png",
graphicOpacity:1.0,
pointRadius:16
},OpenLayers.Feature.Vector.style["default"])),
"select": new OpenLayers.Style(
OpenLayers.Util.applyDefaults({
externalGraphic:"http://maps.gstatic.com/intl/fr_fr/mapfiles/ms/icons/blue-dot.png",
graphicOpacity:1.0,
pointRadius:24
},OpenLayers.Feature.Vector.style["select"])),
"temporary": new OpenLayers.Style(
OpenLayers.Util.applyDefaults({
externalGraphic:"http://maps.gstatic.com/intl/fr_fr/mapfiles/ms/icons/blue-dot.png",
graphicOpacity:1.0,
pointRadius:16
},OpenLayers.Feature.Vector.style["temporary"]))
})
}
), {
// force drawLocation
drawLocation:true,
// tooltip
uiOptions:{title: 'gpControlLocationUtilityService.geonames.title'},
// set appropriate zoom (instead of 10 ...)
setZoom: Geoportal.Control.LocationUtilityService.GeoNames.setZoomForBDNyme,
// turn filters on
//filtersOptions: {},
// turn filters off
filtersOptions: null,
// turn auto-completion off => can use filters !
autoCompleteOptions: null
// turn auto-complete on => no filters
//autoCompleteOptions: {}
});
panel.addControls([gazetteer]);
viewer.getMap().addControls([panel]);
}
/**
* Function: loadAPI
* Load the configuration related with the API keys.
* Called on "onload" event.
* Call <initMap>() 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;
}
Geoportal.GeoRMHandler.getConfig([APIkey], null,null, {
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; |
Partager