0
Google지도에서 여러 마커를 강조 표시하는 방법은 무엇입니까?지도에서 여러 마커를 강조 표시하는 방법
나는 링크와 함께 오른쪽에 열이 나는 테스트를 클릭하면, 나는 휴스턴과 뉴욕
예를 녹색으로 마커를 좋아하는 것 : 당신의 디자인 http://imgur.com/DPr9yeD
var map;
var arrMarkers = [];
var arrInfoWindows = [];
function mapInit(){
var Latlng = new google.maps.LatLng(37.09024,-95.712891);
//var Latlng = new google.maps.LatLng(18.23, -66.39);
var mapOptions = {
zoom: 4,
center: Latlng,
disableDefaultUI: true
};
map = new google.maps.Map(document.getElementById("map"), mapOptions);
$.getJSON("/map.json", {}, function(data){
$.each(data.places, function(i, item){
$("#auteurs_liste").append('<li><a href="#" rel="' + item.id + '" id="auteur_'+item.id+'">' + item.title + '</a></li>');
var marker = new google.maps.Marker({
position: new google.maps.LatLng(item.lat, item.lng),
map: map,
title: item.title,
icon:('http://maps.google.com/mapfiles/ms/icons/red-dot.png')
});
arrMarkers[item.id]= marker;
var contentMarker = [
'<div id="hook">',
'test',
'</div>'
].join('');
var infowindow = new google.maps.InfoWindow({
content: contentMarker
});
arrInfoWindows[item.id] = infowindow;
google.maps.event.addListener(marker, 'click', function() {
$("#auteur_"+item.id).css('color','#941017');
infowindow.open(map, marker);
});
google.maps.event.addListener(marker, 'click', function() {
arrMarkers[item.id].setIcon('http://maps.google.com/mapfiles/ms/icons/green-dot.png');
});
/*
google.maps.event.addListener(arrInfoWindows[item.id],'closeclick',function(){
arrMarkers[item.id].setIcon('http://maps.google.com/mapfiles/ms/icons/red-dot.png');
$("#auteur_"+item.id).css("color",'#000');
});
*/
});
});
}
$(function(){
mapInit();
$("body").on("click", "#auteurs_liste a", function(){
var i = $(this).attr("rel");
for(x=0; x < arrInfoWindows.length; x++){
//arrInfoWindows[x].close();
//arrMarkers[x].setIcon('http://maps.google.com/mapfiles/ms/icons/red-dot.png');
//$("#auteur_"+x).css("color",'#000');
}
//$("#auteur_"+i).css("color",'#941017');
//test force 1
arrMarkers[1].setIcon('http://maps.google.com/mapfiles/ms/icons/green-dot.png');
});
});
감사합니다.하지만 나는 배열을 반복하는 법을 모르겠습니다. 너 한테 모범이 있니? – Kenji