我需要在彈出當有人點擊折線形成許多可用的信息窗口顯示不同的數據不同的信息寡婦,信息與折線谷歌地圖API V3
我看過的很多方案來解決這個這裏是我一個例子來翻過,
Google Maps API - Trouble with Arrays and InfoWindows
但是這種解決方案似乎並沒有爲我工作,它不會顯示信息窗口時,我在一個折線點擊。請幫助我對此...我使用了不同的代碼,它只顯示數組的最後一個元素..我做的是我通過for loop.please添加多段線來幫助我..這是我的代碼,
var map;
var polylinesIn = [];
var infowindow = new google.maps.InfoWindow();
var infowindowArray = [];
function initialize() {
var styles = [{ featureType: "landscape", stylers: [{ color: "#000514"}] }, { featureType: "administrative.country", stylers: [{ weight: 0.1 }, { color: "#009acd"}] }, { featureType: "water", stylers: [{ color: "#1f4fa5dc"}] }, { featureType: "road", stylers: [{ color: "#000514"}] }, { featureType: "administrative.locality", stylers: [{ color: "#7cfc00" }, { visibility: "off"}] }, { featureType: "landscape.man_made", stylers: [{ visibility: "off"}] }, { featureType: "poi", stylers: [{ visibility: "off"}] }, { featureType: "administrative.province", stylers: [{ visibility: "on"}]}];
var mapOptions = {
center: new google.maps.LatLng(7.3, 80.6333),
zoom: 3,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
map.setOptions({ styles: styles });
var lineSymbolIn = {
path: google.maps.SymbolPath.CIRCLE,
scale: 2,
strokeColor: '#FF8000'
};
for (var i = 0; i < 5; i = i + 1) {
var conentVal = i.toString();
//var infowindow = new google.maps.InfoWindow();
var netTrafficIn = [
new google.maps.LatLng(53.3333866 + i, -6.247401 + i),
new google.maps.LatLng(7.3, 80.6333)];
var polylineIn = new google.maps.Polyline({
path: netTrafficIn,
icons: [{ icon: lineSymbolIn, offset: '100%'}],
strokeColor: " #FF8000",
strokeOpacity: 1.0,
strokeWeight: 1,
geodesic: true
});
polylineIn.setMap(map);
polylinesIn[i]=polylineIn;
animateCircleIn(i);
addInfowindow(i.toString());
createInfoWindow(i);
}
}
function addInfowindow(contentVal) {
infowindow = new google.maps.InfoWindow({ content: contentVal });
infowindowArray.push(infowindow);
}
function createInfoWindow(id) {
google.maps.event.addListener(polylinesIn[id], 'click', (function (id) {
return function() {
infowindowArray[id].open(map, polylinesIn[id]);
}
})(id));
}
function animateCircleIn(id) {
var count = 0;
offsetId = window.setInterval(function() {
count = (count + 1) % 200;
var icons = polylinesIn[id].get('icons');
icons[0].offset = (count/2) + '%';
polylinesIn[id].set('icons', icons);
}, 20);
}
非常感謝你:)
奧基我做了一些更改,如巴亞拉建議,但還是信息窗口犯規appear..please help..thank你非常:)
您已經提問此問題。這是相同的情況,在http://stackoverflow.com/questions/11931415/animate-symbol-on-multiple-geodesic-polylines請谷歌「JavaScript封閉」,你可能會學到的東西,而不是一次問相同的問題。 – slawekwin 2012-08-14 08:28:24
嗨,thanx回答以前的1,但我失去了這裏,我試過有功能,但它沒有顯示任何東西:(生病嘗試more..thnx再 – user1584241 2012-08-14 08:39:14
我試圖編輯的代碼,但仍然沒有infowindow :( – user1584241 2012-08-15 05:14:06