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
|
// gestion icone
var icon = new OpenLayers.Layer.Vector('icone', {
styleMap: new OpenLayers.StyleMap({
externalGraphic: 'icons/up.png',
graphicWidth: 24, graphicHeight: 24, graphicYOffset: -12, graphicYOffset: -12,
title: '${tooltip}'
})
});
//boucle mutlipoint en fonction du nombre de champs dans le tableau adherent
for (i = 0; i < adherent.length; i++){
// position a marquer
var point = new OpenLayers.Geometry.Point(adherent[i][10], adherent[i][11])
.transform('EPSG:4326', 'EPSG:900913');
// liaison point/icone/popup
icon.addFeatures([
new OpenLayers.Feature.Vector(point, {tooltip: 'OpenLayers'})
]);
// declaration du popup avec son contenu
var popup = new OpenLayers.Popup.FramedCloud("Popup",
point.getBounds().getCenterLonLat(), null,
''+adherent[i][3]+' '+adherent[i][4]+'<br>'+adherent[i][5]+'<br>'+adherent[i][6]+'<br>', null,
true // <-- true si on veut fermer le popup avec le bouton (X), false sinon
);
}
// au final on créé la carte dans la div map
//declaration du centre de la carte
var centre=new OpenLayers.LonLat(0,0) // Centre de la carte
centre=centre.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
new OpenLayers.Projection("EPSG:900913") // to Spherical Mercator Projection
);
var zoom=11;
carte = new OpenLayers.Map({
div: "map", projection: "EPSG:900913",
layers: [new OpenLayers.Layer.OSM(), icon],
});
carte.setCenter(centre,zoom);
carte.addPopup(popup); |
Partager