2016-10-23 2 views
0

Google지도 마커에 표시 할 JSON 데이터를로드하고 싶습니다. Jquery getJSON 메서드를 사용하여 서버에서 JSON 데이터를 호출했습니다. 그러나지도는 나타나지만 마커는 나타나지 않습니다. 여기에 코드 Google지도의 마커에 JSON 데이터가 표시되지 않습니다.

var map; 
 
    
 
    function initialize() { 
 
    
 
     var mapProp = { 
 
       center: new google.maps.LatLng(28.003389000000, -82.429500000000), 
 
       zoom: 5, 
 
       mapTypeId: google.maps.MapTypeId.ROADMAP 
 
      }; 
 

 
     map = new google.maps.Map(document.getElementById("map"), mapProp); 
 
     $.getJSON('http://tripleclickstudio.com/json/file.json?callback=?', function (json1) { 
 
    
 
      $.each(json1.ResponseData, function (key, data) { 
 

 
       var latLng = new google.maps.LatLng(data.CoordinateY, data.CoordinateX), 
 
        marker = new google.maps.Marker({ 
 
         position: latLng, 
 
         map: map, 
 
         title: data.BuildingName 
 
        }), 
 
        details = data.BuildingName + ", " + data.Location + "."; 
 
       
 
      }); 
 

 
     }); 
 
    } 
 
    var infowindow = new google.maps.InfoWindow(); 
 
    function bindInfoWindow(marker, map, infowindow, strDescription) { 
 
     
 
     google.maps.event.addListener(marker, 'click', function() { 
 
      infowindow.setContent(strDescription); 
 
      infowindow.open(map, marker); 
 
     }); 
 
     bindInfoWindow(marker, map, infowindow, details); 
 
    } 
 

 
    google.maps.event.addDomListener(window, 'load', initialize); 
 
<script src="https://maps.googleapis.com/maps/api/js"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div id="map" style="border: 2px solid #3872ac;"></div>

이 내 JSON 파일 JSON 파일의 링크입니다

입니다. 자, 여기에 JSON 데이터 좌표가 Google지도의 마커로 표시되기를 바랍니다. 그래서, 어떤 사람이 나에게 어떤 실수를했는지 그리고이 문제를 해결하기 위해 무엇을해야하는지 알려줍니다. 감사합니다

+0

브라우저 개발자 도구 콘솔에 오류가 있습니까? –

답변

0

그냥 json URL에서 ?callback=?을 제거하십시오.

구문은 JSON P이고 파일 내용은 JSON입니다.

관련 문제