2013-03-13 3 views
0

Google지도 InfoWindow를 동적으로 Wordpress에 추가하려고합니다. 이것은 현재 사용자 정의 마커로 작업하고있는 코드입니다. infowindow에 대해 여러 가지 기능을 시도했지만 코드가 깨지거나로드되지 않는 것 같습니다. 지도. 내가 뭘 잘못하고 있을지 모르겠다. 이 작품Google지도 추가하기 InfoWindow 동적으로 Wordpress

은 그냥 정보창을 추가 할 필요가

간단한 infowindow은 (테스트하지) 될
<script type="text/javascript"> 
       //<![CDATA[ 

       function load() { 
       var styles = 
       [ 
        { 
         "stylers": [ 
         { "lightness": 1 }, 
         { "saturation": -76 }, 
         { "hue": "#3bff00" } 
         ] 
        } 
        ]; 


       var lat = <?php echo $lat; ?>; 
       var lng = <?php echo $lng; ?>; 
       // coordinates to latLng 
       var latlng = new google.maps.LatLng(lat, lng); 
       // map Options 

       var myOptions = { 

       zoom: 14, 
       scrollwheel: false, 
       center: latlng, 
       mapTypeId: 'Styled' 
       }; 

       //draw a map 
       var map = new google.maps.Map(document.getElementById("map"), myOptions); 
       var styledMapType = new google.maps.StyledMapType(styles, { name: 'Styled' }); 
       map.mapTypes.set('Styled', styledMapType); 
       var marker = new google.maps.Marker({ 
       position: map.getCenter(), 
       map: map, 
       icon: '/wp-content/themes/bills_theme/images/pin_bills.png', 
       }); 
       } 
       // call the function 
       load(); 
       //]]> 

      </script> 
+0

코드에 InfoWindow가 표시되지 않습니다. InfoWindow에 표시 할 데이터의 출처와 작동하지 않는 정보에 대한 정보를 추가하십시오. – geocodezip

답변

0

:

var contentString = 'put your content here.'; 
google.maps.event.addListener(marker, 'click', function() { 
    var infowindow = new google.maps.InfoWindow({ 
     content: contentString, 
     position: latlng, 
     maxWidth: 200 
     }); 
    infowindow.open(map); 
}); 

더 :

  //draw a map 
      var map = new google.maps.Map(document.getElementById("map"), myOptions); 
      var styledMapType = new google.maps.StyledMapType(styles, { name: 'Styled' }); 
      map.mapTypes.set('Styled', styledMapType); 
      var marker = new google.maps.Marker({ 
      position: map.getCenter(), 
      map: map, 
      icon: '/wp-content/themes/bills_theme/images/pin_bills.png', 
      }); 
      var infowindow = new google.maps.InfoWindow(); 
      google.maps.event.addListener(marker, "click", function(e) { 
      infowindow.setContent("Hello world"); 
      infowindow.open(map,marker); 
      }); 
      google.maps.event.trigger(marker, "click"); 
      } 
      // call the function 
+0

그게 작동하지 않는 인스턴트 메신저 :( – mariovass

+0

어쩌면 당신은 위의 이외의 시도에 대해 위의 내 질문에 대답 할 수 있습니다. 자바 스크립트 오류가 발생합니까? infowindow를 클릭하면 작동합니까? 나는 고쳤지만, 당신에게 오류를 주었어 야했다. – geocodezip

0

그냥이 코드를 추가 Info Window에 대한 정보는 HERE을 읽을 수 있습니다.

관련 문제