私は、リモートで座標を取得し、マップ上に配置し、それらをポリラインに接続するクリックイベントを持っています。私は同じことをする他のクリックイベントを持っていますが、別のレイヤーとしてそれらを保持して、ユーザーが行ったクリックのそれぞれを表示するように切り替えることができます。誰かがこれを別々にグループ化して別の方法をとる良い方法を知っていますか?ここでGoogleマップで複数のオーバーレイを切り替えるにはどうすればよいですか?
は私のコードは、これまでのところです:あなたがそれらを持っている
drawPoints: function (points, color) {
$.each(points, function (key, val) {
var location = new google.maps.LatLng(val.Latitude, val.Longitude);
MyTest.addMarker(location, val.Name, val.Description);
MyTest.coordinates.push(location);
});
this.path = new google.maps.Polyline({
path: MyATest.coordinates,
strokeColor: color,
strokeOpacity: 1.0,
strokeWeight: 2
});
this.path.setMap(this.googlemap);
},
addMarker: function (location, title, html) {
var marker = new google.maps.Marker({
position: location,
map: this.googlemap,
title: title,
html: html
});
this.markers.push(marker);
},
// Removes the overlays from the map, but keeps them in the array
clearOverlays: function() {
if (this.markers) {
for (i in this.markers) {
this.markers[i].setMap(null);
}
}
},
// Shows any overlays currently in the array
showOverlays: function() {
if (this.markers) {
for (i in this.markers) {
this.markers[i].setMap(map);
}
}
},
ヒジャブラブは、このフィドルを始めにして、ここにそれを複製してください:http://jsfiddle.net/fHsAY/ :))素晴らしいものがあります! cheerios! –