2017-04-04 4 views
0

이것은 체스 프레임 워크 프로젝트를위한 것입니다. API 키로 작업 한 후에도 콘솔에서 오류가 발생하지 않지만 표시가 여전히 거부됩니다. 나는 여기에 오류를 찾는 데 도움을 주셔서 감사합니다. 나는 단지 그것을 보지 않고있다.Google지도에 오류가 표시되지 않지만 표시되지 않습니다.

<?php /* Static Name: Map */ ?> 
<style type="text/css"> 
    /* Set a size for our map container, the Google Map will take up 100% of this container */ 
    #map { 
     width: 100%; 
     height: 391px; 
    } 
</style> 
<script type="text/javascript"> 
    // When the window has finished loading create our google map below 
    google.maps.event.addDomListener(window, 'load', init); 

    function init() { 

     // The latitude and longitude to center the map (always required) 
     var myLatlng = new google.maps.LatLng(<?php echo of_get_option('latitude'); ?>, <?php echo of_get_option('longitude'); ?>); 

     // Basic options for a simple Google Map 
     // For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions 
     var mapOptions = { 
      // How zoomed in you want the map to start at (always required) 
      zoom: <?php echo of_get_option('zoom'); ?>, 

      scrollwheel: false, 

      // The latitude and longitude to center the map (always required) 
      center: myLatlng, // Santa Barbara 

      // How you would like to style the map. 
      // This is where you would paste any style found on Snazzy Maps. 
      styles: 
      [ 
    { 
     "featureType": "water", 
     "elementType": "all", 
     "stylers": [ 
      { 
       "hue": "#76aee3" 
      }, 
      { 
       "saturation": 38 
      }, 
      { 
       "lightness": -11 
      }, 
      { 
       "visibility": "on" 
      } 
     ] 
    }, 
    { 
     "featureType": "road.highway", 
     "elementType": "all", 
     "stylers": [ 
      { 
       "hue": "#8dc749" 
      }, 
      { 
       "saturation": -47 
      }, 
      { 
       "lightness": -17 
      }, 
      { 
       "visibility": "on" 
      } 
     ] 
    }, 
    { 
     "featureType": "poi.park", 
     "elementType": "all", 
     "stylers": [ 
      { 
       "hue": "#c6e3a4" 
      }, 
      { 
       "saturation": 17 
      }, 
      { 
       "lightness": -2 
      }, 
      { 
       "visibility": "on" 
      } 
     ] 
    }, 
    { 
     "featureType": "road.arterial", 
     "elementType": "all", 
     "stylers": [ 
      { 
       "hue": "#cccccc" 
      }, 
      { 
       "saturation": -100 
      }, 
      { 
       "lightness": 13 
      }, 
      { 
       "visibility": "on" 
      } 
     ] 
    }, 
    { 
     "featureType": "administrative.land_parcel", 
     "elementType": "all", 
     "stylers": [ 
      { 
       "hue": "#5f5855" 
      }, 
      { 
       "saturation": 6 
      }, 
      { 
       "lightness": -31 
      }, 
      { 
       "visibility": "on" 
      } 
     ] 
    }, 
    { 
     "featureType": "road.local", 
     "elementType": "all", 
     "stylers": [ 
      { 
       "hue": "#ffffff" 
      }, 
      { 
       "saturation": -100 
      }, 
      { 
       "lightness": 100 
      }, 
      { 
       "visibility": "simplified" 
      } 
     ] 
    }, 
    { 
     "featureType": "water", 
     "elementType": "all", 
     "stylers": [] 
    } 
] 
     }; 

     // Create the Google Map using out element and options defined above 
     var map = new google.maps.Map(document.getElementById('map'), mapOptions); 

     var contentString = '<div id="content"><?php $desc = of_get_option("description"); echo str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $desc); ?></div>'; 
     var infowindow = new google.maps.InfoWindow({ 
      content: contentString 
     }); 

     var image = '<?php echo get_stylesheet_directory_uri(); ?>/images/marker.png'; 

     var marker = new google.maps.Marker({ 
      position: myLatlng, 
      map: map, 
      icon: image 
     }); 

     // To add the marker to the map, call setMap(); 
     marker.setMap(map); 

     google.maps.event.addListener(marker, 'click', function() { 
      infowindow.open(map,marker); 
     }); 

    } 
</script> 
<div id="map"></div> 

답변

0

Google지도에 액세스하는 데 필요한 JQuery와 Google지도 API 키 라이브러리가 없습니다. 키 API를 추가해야합니다.

여기의 지시를 따르십시오 : Google Map Api Key help

0

related SO post로 참조 할 수 있습니다. 귀하의 코드를 기반으로, 나는 당신이 제대로 Google Maps를로드하지 않는 것 같아요. 이 example을 확인하십시오.

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=<your_api_key&sensor=false&callback=initialize"></script> 
관련 문제