bonjour,
j’ai un petit souci sur ma carte :
mes points sont bien positionnés quand je suis au niveau de zoom maximum mais quand je dézoome ils se décallent progressivement.
voici mon code :
<script>
var map;
function init(){
map = new OpenLayers.Map({
div: "map",
controls: [
new OpenLayers.Control.Navigation({
dragPanOptions: {
enableKinetic: true
}
}),
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.Zoom({
zoomInId: "customZoomIn",
zoomOutId: "customZoomOut"
})
],
center: [0, 0],
zoom: 1
});
var wms = new OpenLayers.Layer.OSM();
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
var size = new OpenLayers.Size(150,25);
var cloudmade = new OpenLayers.Layer.CloudMade("CloudMade", {
key: 'xxxxx',
styleId: <?php echo $id_map;?>
});
var layer = new OpenLayers.Layer.Vector("POIs", {
strategies: [new OpenLayers.Strategy.BBOX({resFactor: 0.0})],
protocol: new OpenLayers.Protocol.HTTP({
url: "dynamic/poi/poi_admin.txt",
format: new OpenLayers.Format.Text()
})
});
var position = new OpenLayers.LonLat(5.373259,43.282704).transform( fromProjection, toProjection);
var zoom = 14;
map.addLayers([cloudmade, layer]);
map.zoomToMaxExtent();
map.setCenter(position, zoom );
selectControl = new OpenLayers.Control.SelectFeature(layer);
map.addControl(selectControl);
selectControl.activate();
layer.events.on({
'featureselected': onFeatureSelect,
'featureunselected': onFeatureUnselect
});
}
// Needed only for interaction, not for the display.
function onPopupClose(evt) {
// 'this' is the popup.
var feature = this.feature;
if (feature.layer) { // The feature is not destroyed
selectControl.unselect(feature);
} else { // After "moveend" or "refresh" events on POIs layer all
// features have been destroyed by the Strategy.BBOX
this.destroy();
}
}
function onFeatureSelect(evt) {
feature = evt.feature;
title = feature.attributes.t;
description = feature.attributes.d;
tel = feature.attributes.tel;
fax = feature.attributes.fax;
popup = new OpenLayers.Popup.FramedCloud("featurePopup",feature.geometry.getBounds().getCenterLonLat(),new OpenLayers.Size(200,100),description+"<br>Tél: "+tel+"<br>Fax"+fax+"","<h2>"+title+"</h2>" +null, true, onPopupClose);
feature.popup = popup;
popup.feature = feature;
map.addPopup(popup, true);
}
function onFeatureUnselect(evt) {
feature = evt.feature;
if (feature.popup) {
popup.feature = null;
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
}
var fromProjection = new OpenLayers.Projection("EPSG:4326"); // Transform from WGS 1984
var toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
var center = new OpenLayers.LonLat(-0.137, 51.514).transform(fromProjection, map.getProjectionObject());
</script>
merci pour votre aide
cordialement