2012-04-23 2 views
0

그래서 나는이 같은 동적으로로드 내가 일하고 있어요지도를 가지고 마커 팝업을 클릭 : 나는 우아 마커를로드되어 수행 할 작업을동적으로로드 구글지도 API는 :

foreach($myposts as $post) : setup_postdata($post); ?>         

    var marker<?php echo $count; ?> = new google.maps.Marker({ position: new google.maps.LatLng<?php the_field('longlat'); ?>, map: map, title:"<?php the_title(); ?>, <?php the_field('address'); ?>", icon:image }); 

    google.maps.event.addListener(marker<?php echo $count; ?>, 'click', function() 
    { 

     alert('you clicked: <?php the_title(); ?> - <?php the_field('address'); ?>'); 

    }); 

    <?php $count++ ?> 

    <?php endforeach; ?> 

PHP에서이 두 값 인 제목과 주소를 팝업 ... : 그것은하지만 경고에 ...

그래서 나는이를 설정하는 방법이 않는다 현재

<?php the_title(); ?> - <?php the_field('address'); ?> 

는 그래서 그것은 나타납니다 마커 위의 팝업?

도와 주셔서 감사합니다. 에 https://developers.google.com/maps/documentation/javascript/reference#InfoWindow

도 관련 코드 샘플 : 당신은 당신이 뭔가를 넣을 수 있습니다 경고 코드가 https://developers.google.com/maps/documentation/javascript/demogallery

답변

1

난 당신의 infoWindow 클래스와 관련 문서를 확인하시기거야 like :

var infowindow = new google.maps.InfoWindow(); 
infowindow.setContent('Whatever you want in the popup'); 
infowindow.open(map, this);