[Talk-it] mapbox marker nella posizione giusta solo al massimo zoom
Zardetto Carlo
carlo a artmediastudio.com
Mer 19 Feb 2014 11:10:22 UTC
Salve ho un problema e me ne sono accorto solo ora e volevo sapere se qualcuno mi può dare una mano.
Sto usando le mapbox.js versione 1.4 per la gestione delle OSM.
Carico la mappa con uno zoom 14.
var map = L.mapbox.map('map', 'xxxxxxx.map-h6zjbw6j').setView([xx.xxxxxxx,y.yyyyyyy], 14);
var ico=L.icon({iconUrl:'icone/amenity/1.png', iconSize:[47, 47],iconAnchor:[25,25],popupAnchor:[0,-15]});
A questo punto uso delle chiamate asincrone per popolare la mappa con i punti di interesse
seguendo l’ esempio http://leafletjs.com/examples/geojson.html
function loadLayer(url)
{
CancellaLinea() ;
//myLayer.features([]);
InzioLayer=true;
myLayer = L.geoJson(url,
{
onEachFeature:function onEachFeature(feature, layer)
{
if (feature.geometry.type!="Point")
{
obj=$.geo.centroid(feature.geometry);
layer=L.marker(L.latLng(obj.coordinates[1],obj.coordinates[0]), {icon:ico});
}
if (feature.properties && feature.properties.name)
{
// layer.bindPopup(feature.properties.name+"<br/><a href='http://www.openstreetmap.org/browse/"+feature.properties["@type"]+"/"+feature.properties["@id"]+"'>Guarda su OSM</a>");
layer.bindPopup("<div class=\"marker-title\">"+feature.properties.name+"</div>"
+"<br/><div class=\"marker-description\">"+feature.properties.description
+"</div>");
}
},
pointToLayer: function (feature, latlng)
{
ico=L.icon({iconUrl:feature.properties.icon.iconUrl, iconSize:[feature.properties.icon.iconSize],iconAnchor:[0,-25]});
var marker=L.marker(latlng, {icon:ico});
return marker;
}
});
myLayer.addTo(map);
myLayer.on('mouseover', function(e) {
// e.layer.openPopup();
});
myLayer.on('mouseout', function(e) {
// e.layer.closePopup();
});
myLayer.on('click', function(e) {
map.panTo(e.layer.getLatLng());
});
}
E i punti di interesse compaiono sulla mappa con le relative dialogbox.
Il problema è che i punti risultano essere nella posizione giusta solo al massimo zoom mentre a zoom più alti traslano e si trovano fuori posizione.
Qualcuno sa dove posso avere sbagliato o se manca una funzione che relativizza la posizone a seconda dello zoom ?
Grazie in anticipo
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.openstreetmap.org/pipermail/talk-it/attachments/20140219/5b5ad3d4/attachment-0001.html>
Maggiori informazioni sulla lista
Talk-it