English 中文(简体)
每次活动聆听人使用谷歌地图3中一个变量的一组标识——坡道、关闭
原标题:Attach event listeners to a set of markers using one variable in Google Maps v3 - loop, closure

I ve利用一个变量中的阵列建立了一套标识。 d 我愿加上“立克”活动,聆听每个标识,这些标记与阵列中每个项目具体注明的圆顶连接。 以下职能完全是EXCEPT的,它把阵列中的最后一 分配给所有标识(而不是将头角和第二升到第二标记等等)。 其余数据被适当分配。 我知道,解决办法涉及 lo门的关闭,但我可以说明如何妥善创造。 任何帮助都会受到高度赞赏。

var tours = [

[ Title 1 , 35.22024012078826, -80.81088066101074,  tour/1 ],
[ Title 2 , 35.20376057077245, -80.84718704223633,  tour/2 ]

];


setTourMarkers(map, tours);


function setTourMarkers(map, locations) {


var tourImage = new google.maps.MarkerImage( http://www.tours.com/images/camera-icon.png ,
  new google.maps.Size(27, 22),
  new google.maps.Point(0,0),
  new google.maps.Point(14, 11));


var tourShape = {
  coord: [1, 1, 1, 27, 27, 22, 22 , 1],
  type:  poly 
};


for (var i = 0; i < locations.length; i++) {
  var tour = locations[i];
  var tourLatLng = new google.maps.LatLng(tour[1], tour[2]);
  var marker = new google.maps.Marker({
  position: tourLatLng,
  map: map,
  icon: tourImage,
  shape: tourShape,
  title: tour[0]

  }); //End new google.maps.Marker

  google.maps.event.addListener(marker,  click , function() {
    window.location.href = "http://www.tours.com/" + tour[3];

  }); //End google.maps.event.addListener

}; // End "for" statement ***************


}; // End setTourMarkers function
问题回答

www.un.org/Depts/DGACM/index_spanish.htm Origianlly在原始海报上登出,但将其作为问题的一部分。 回答:

图2. 活动听众的变化

google.maps.event.addListener(marker,  click , (function(tour) {
return function(){
  window.location.href = "http://www.tours.com/" + tour[3];
    }

})(tour)); //End google.maps.event.addListener




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签