2012-09-26 3 views
0

Google지도 Api를 구현하고 Wordpress 데이터베이스에서 마커를로드 할 수있었습니다. 하지만 사용자 정의 아이콘을 마커 핀에 추가하는 방법을 알 수 없습니다. 문제는 Wordpress가 템플릿 파일에 대한 직접 액세스를 허용하지 않는다는 것입니다.Google지도 API 마커, Wordpress 및 jQuery

내 이미지가 테마에로드

/THEMENAME/IMG/BGI 스크립트는 다음과 같습니다

: 나는 내 솔루션에 대해 다음 사용

var myLatlng = new google.maps.LatLng(data[i].latitude,data[i].longitude); 
        marker = new google.maps.Marker({ 
          position: myLatlng, 
          //icon: data[i].image, 
          map: map, 
          title: data[i].title 
        }); 
+0

Google Maps API 문서를 읽지 않으셨습니까? – trickyzter

+0

여러 번 읽었습니다. 마커 아이콘의 WordPress 또는 PHP 로딩에 대한 사양은 없습니다. 또는 어쩌면 나는 그것을 발견하지 못했습니다 ... –

+0

Google Maps API v3 문서가 wordpress 또는 PHP에 대해 어떤 말을 사용합니까? [맞춤 아이콘 아이콘] (https://developers.google.com/maps/documentation/javascript/overlays#SimpleIcons)을 구현하는 방법을 알려줍니다. – geocodezip

답변

2

- 테마 디렉토리에있는 파일에 대한 절대 경로를 :

<?php bloginfo('template_directory'); ?>/img/marker.png 
<?php bloginfo('template_directory'); ?>/img/marker-shadow.png 

그래서 당신은 :

var image = new google.maps.MarkerImage('<?php bloginfo('template_directory'); ?>/img/marker.png', 
    new google.maps.Size(60,78), 
    new google.maps.Point(0,0), 
    new google.maps.Point(30,78) 
); 
var shadow = new google.maps.MarkerImage('<?php bloginfo('template_directory'); ?>/img/marker-shadow.png', 
    new google.maps.Size(105,78), 
    new google.maps.Point(0,0), 
    new google.maps.Point(30,78) 
); 
관련 문제