0
API에서 정보를 얻고 있습니다. 지오 코더를 호출하여 점을 얻은 다음 정보창에 텍스트가있는 마커를 만듭니다. 내 마커는 문제없이지도에 배치됩니다.Google지도의 infowindow에 대한 설명
마커를 클릭하면 항상 동일한 텍스트가 표시됩니다. 나는 마커를 클릭하면 '미리 채우기'에 정보창이 그래서 올바른 정보를 표시하는 방법 는 내가 충분히 분명 희망
function createMarker(point, text) {
alert('point: ' + point + 'text: ' + text)
var html ="<div class='infowindow'><strong>"+ text + "<\/strong><\/div>";
//var marker = new GMarker(point, markerOptions);
var marker = new google.maps.Marker({
map: map,
position: point
});
infowindow = new google.maps.InfoWindow({
content: html
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
return marker;
}
... 알아낼 수 없습니다! 나는 구글 API의 V3를 사용하고
다음 코드를 사용하여 해결 :
function createMarker(point, text) {
//var html ="<div class='infowindow'><strong>"+ text + "<\/strong><\/div>";
//var marker = new google.maps.Marker({
// map: map,
// position: point
//});
//infowindow = new google.maps.InfoWindow({
// content: html
//});
//google.maps.event.addListener(marker, 'click', function() {
// infowindow.open(map, marker);
//});
//return marker;
var title = 'LinkedIn Connection';
var html = "<div class='infowindow'><strong>"+ text + "<\/strong><\/div>";
var marker = new google.maps.Marker({
title:title,
content:html,
map:map,
draggable:false,
position:point
});
google.maps.event.addListener(marker, 'click', function() {
/* close the previous info-window */
closeInfos();
/* the marker's content gets attached to the info-window: */
var info = new google.maps.InfoWindow({content: this.content});
/* trigger the infobox's open function */
info.open(map,this);
/* keep the handle, in order to close it on next click event */
infos[0]=info;
});
}
function closeInfos(){
if(infos.length > 0){
/* detach the info-window from the marker */
infos[0].set("marker",null);
/* and close it */
infos[0].close();
/* blank the array */
infos.length = 0;
} } 당신은에 결과를 확인할 수 있습니다
을 여기 : www.pukkafish.com/api/linkedin. linkedIn 계정이 필요합니다. – Olivier