JSON (V3)에 마커를 표시 할 수 없습니다구글지도 API 내가 데이터베이스의 PostgreSQL를 JSON과 구글 맵을 생성하고 사용
이 (텍스트) 내 코드
<script type="text/javascript">
var map;
var national = [{"lng":"-6.173319","city":"JAKARTA","lat":"106.818672"}];
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-0.789275,113.921327),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
$.getJSON('json_city.json', function(data) {
$.each(data.national, function(index, item) {
var myLatlng = new google.maps.LatLng(item.lat, item.lng);
alert(myLatlng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: "text "+item.city
});
});
});
// Initialize the map
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
위도 및 긴 사용하는 문자 유형 . 내지도는 표시 할 수 있지만 내 마커는 표시 할 수 없습니다.
당신은 'national' 변수에 오타가 있습니다. 'lat'와'lng'는 뒤로입니다 (''lat ":"-6.173319 ","lng ":"106.818672 "'). ([바이올린] (http://jsfiddle.net/geocodezip/f3rwcdyd/)) – geocodezip
고맙습니다. @geocodezip –