0
나는 버디 프레스를 사용 중이며 프로필에 Google지도를 추가했습니다. 때로는지도가 올바르게 표시되고 때로는 표시되지 않는 경우도 있습니다. Google지도 오류 예기치 않은 구문 오류 : 예기치 않은 토큰)
나는지도가 "catch되지 않은 구문 오류를 표시하고하지 않는 페이지의"요소 검사 "검사 : 그 누구도 날이 누락 된지도 문제를 해결하는 데 도움이 될 수 있습니다 예기치 않은 토큰) 여기 은 PHP 코드입니다 참조 :<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
if (jQuery('#member-map').length != 0) {
function a_page_maps() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(26.745610382199022, 2.63671875);
var myOptions = {
zoom: 2,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("member-map"), myOptions);
var gmarkers = [];
function createMarker(latlng,html,url,icon) {
var contentString = html;
var marker = new google.maps.Marker({
position: latlng,
map: map,
icon: icon
});
gmarkers.push(marker);
var infowindow = new google.maps.InfoWindow;
google.maps.event.addListener(marker, 'mouseover', function() {
infowindow.setContent(contentString);
infowindow.open(map,marker);
});
google.maps.event.addListener(marker, 'mouseout', function() {
infowindow.close(map,marker);
});
google.maps.event.addListener(marker, 'click', function() {
window.location = url;
});
}
<?php
foreach ($placel as $place) {
if(get_post_meta($place, 'article_location', true) <> "") {
?>
var image = '<?php echo get_bloginfo('template_url'); ?>/images/red-pushpin.png';
var point = new google.maps.LatLng(<?php echo get_post_meta($place, 'article_location_latlon', true); ?>);
var html = "<h5><?php echo get_post_meta($place, 'article_location', true); ?></h5><p class='popup'><em>↓ Click to see articles about this location ↓</em></p>";
var url = '<?php echo get_bloginfo('wpurl'); ?>/locations/?location=<?php echo urlencode(get_post_meta($place, 'article_location', true)); ?>';
var marker = createMarker(point,html,url,image);
<?php
}
}
?>
<?php
foreach ($placegol as $placego) {
if(get_post_meta($placego, 'article_location', true) <> "") {
?>
var image = '<?php echo get_bloginfo('template_url'); ?>/images/grn-pushpin.png';
var point = new google.maps.LatLng(<?php echo get_post_meta($placego, 'article_location_latlon', true); ?>);
var html = "<h5><?php echo get_post_meta($placego, 'article_location', true); ?></h5><p class='popup'><em>↓ Click to see articles about this location ↓</em></p>";
var url = '<?php echo get_bloginfo('wpurl'); ?>/locations/?location=<?php echo urlencode(get_post_meta($placego, 'article_location', true)); ?>';
var marker = createMarker(point,html,url,image);
<?php
}
}
?>
}
a_page_maps();
}
});
</script>
오류 메시지는 코드에서 하나의')'가 누락되었다는 것을 의미합니다. Firebug (FF 용) 또는 내장 된 Dev Tools (Chrome & Safari)와 같은 디버깅 도구를 사용하면 문자가없는 정확한 행을 알려줍니다! 일반적으로 클릭 할 수있는 각 구문 오류 옆에 줄 번호가 표시되어 시간에 오류가 표시되고 수정됩니다. [this for example] (http://getfirebug.com/javascript) – m90
결과 자바 스크립트 코드를 질문에 추가하는 것이 합리적 일 수 있습니다. PHP보다 자바 스크립트 오류를 쉽게 발견 할 수 있어야합니다. – lnrbob