Ciao ragazzi praticamente non funziona il for in questo pezzo di codice e non capisco proprio il perché :
codice:
function initialize() {
var mapDiv = document.getElementById('map_canvas');
var myOptions = {
zoom: 2,
center: new google.maps.LatLng(0.0, 0.0),
mapTypeId: google.maps.MapTypeId.TERRAIN,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
position: google.maps.ControlPosition.TOP_CENTER
},
panControl: true,
panControlOptions: {
position: google.maps.ControlPosition.TOP_RIGHT
},
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.LARGE,
position: google.maps.ControlPosition.TOP_RIGHT
},
scaleControl: true,
scaleControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER
}
};
// Create a script tag and set the USGS URL as the source.
var script = document.createElement('script');
script.src = 'http://earthquake.usgs.gov/earthquakes/feed/v0.1/summary/2.5_week.geojsonp';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(script, s);
map = new google.maps.Map(mapDiv, myOptions);
infoWindow = new google.maps.InfoWindow();
}
questo primo pezzo crea la mappa di Google ed è OK.. poi:
codice:
window.eqfeed_callback = function(results) {
var shape = {
coord: [1, 1, 1, 20, 18, 20, 18 , 1],
type: 'poly'
};
for (var i = 0; i < results.features.length; i++) {
var sism = results.features[i];
var timeeq = results.features[i].properties.time;
var coords = results.features[i].geometry.coordinates;
var mag = results.features[i].properties.mag;
var place = results.features[i].properties.place;
var latLng = new google.maps.LatLng(coords[1], coords[0]);
var marker = new google.maps.Marker({
position: latLng,
map: map,
title: place + timeeq,
shape: shape,
flat: true
});
google.maps.event.addListener(marker, 'click', function() {
var myHtml = '<div style="font-weight: bold; font-size: medium; margin-bottom: 0em;" jstcache="0">'+ place + '</div>' + timeeq;
infoWindow.setContent(myHtml);
infoWindow.open(map, marker);
});
è la funzione che serve a creare dei marker per ogni evento sismico. Prendendo i dati da
http://earthquake.usgs.gov/earthquak..._week.geojsonp
Praticamente non mi funziona l'ultimo parte, ovvero:
google.maps.event.addListener(marker, 'click', function() {
var myHtml = '<div style="font-weight: bold; font-size: medium; margin-bottom: 0em;" jstcache="0">'+ place + '</div>' + timeeq;
infoWindow.setContent(myHtml);
infoWindow.open(map, marker);
});
che dovrebbe crearmi un fumetto ogni volta che clicco un marker, visualizzandomi i corretti valori corrispondenti a "place" e "timeeq" (corretti se il "FOR" funzionasse anche per questo pezzo di codice)
e invece su qualsiasi marker clicco mi si apre il fumetto del marker corrispondente all'ultimo evento sismico del file.
Ovvero come se "place" e "timeeq" fossero:
codice:
var place = results.features[0].properties.place;
var timeeq = results.features[0].properties.time;
quando invece tra le parentesi quadre dovrebbe corrispondere "i" ....
Quindi perché non funziona?????????????

GRAZIE