<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>API Geoportail - Situation de la données</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
div#viewerDiv {
width:800px;
height:600px;
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[//><!--
window.onload= function() {
Geoportal.load(
// div's ID:
'viewerDiv',
// API's keys:
['La clé...'],
{// map's center :
// longitude:
lon:-.4,
// latitude:
lat:46.65 },
//zoom
15,
//options
{overlays:{}, //sert à enlever la punaise au centre de la carte qui existe par défaut
viewerClass:Geoportal.Viewer.Default //pour mettre la boite à outil standard
}; { label:'Pierre dite du "Nombril"',
description:'Voir le nombril du monde sur <a href="http://fr.wikipedia.org/wiki/Pougne-H%C3%A9risson" target="_blank" title="Wikipedia">Wikipedia</a>',
viewerClass:Geoportal.Viewer.Default,
layers:['TRANSPORTNETWORKS.ROADS:WMSC', 'CADASTRALPARCELS.PARCELS:WMSC',
'BUILDINGS.BUILDINGS:WMSC'],
layersOptions:{'TRANSPORTNETWORKS.ROADS:WMSC':{visibility:false,opacity:0.45, minZoomLevel:1,maxZoomLevel:15},
'CADASTRALPARCELS.PARCELS:WMSC':{visibility:true, minZoomLevel:16, maxZoomLevel:20},
'BUILDINGS.BUILDINGS:WMSC':{visibility:false,opacity:0.9, minZoomLevel:12,maxZoomLevel:15}}
};
// Creation d’un point
var mon_point = new OpenLayers.Geometry.Point(-0.4, 46.65);
// Passage en projection Géoportail
var sourceproj = OpenLayers.Projection.CRS84; // WGS84
var destproj = VISU.projection; // projection Geoportail
mon_point.transform(sourceproj, destproj);
// Création du POI à partir du point
var stylepoi = {externalGraphic:'http://api.ign.fr/geoportail/api/js/1.0beta4/theme/geoportal/img/picto_zoomToMapExtent_ off.gif', graphicWidth:50, graphicHeight:50 };
var mon_poi = new OpenLayers.Feature.Vector(mon_point, null, stylepoi);
// Ajout d’une couche d'objet vectoriels
var vector_layer = new OpenLayers.Layer.Vector('Mes POIs');
// Ajout du POI à la couche créée et affichage de la couche
vector_layer.addFeatures([mon_poi]);
// Ajout de la couche à la carte
VISU.getMap().addLayer(vector_layer);
// Ajout de l’info bulle
var popup = new OpenLayers.Popup('id',
new OpenLayers.LonLat(mon_point.x, mon_point.y),
new OpenLayers.Size(200,50),
'Ma Première info bulle',
true
);
// Ajout de l’info bulle
VISU.getMap().addPopup(popup, true);
);
//--><!]]></script>
<script
type="text/javascript"
src="http://api.ign.fr/geoportail/api/js/1.3/Geoportal.js">
<!-- -->
</script>
</body>
</html>
Partager