지도 API V3 및 지역 검색을 구현하려고하는데 문제가있는 것 같습니다. 아무 래도 OnLocalSearch() 함수의 결과가 비어 있습니다.Google지도 API V3 및 지역 검색 문제 - 결과가 비어 있습니까?
여기 내 전체 코드입니다 :
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
// do stuff when DOM is ready
var geocoder = new google.maps.Geocoder();
var address = '{{string_location}}';
var map;
// Our global state for LocalSearch
var gInfoWindow;
var gSelectedResults = [];
var gCurrentResults = [];
var gLocalSearch = new GlocalSearch();
if (geocoder) {
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
//alert(results[0].geometry.location.lat())
//alert(results[0].geometry.location.lng())
//Create the Map and center to geocode results latlong
var latlng = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng());
var myOptions = {
zoom: 14,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
gLocalSearch.setSearchCompleteCallback(this, OnLocalSearch);
gLocalSearch.execute("{{business_item.name}}");
}
else {
alert('No results found. Check console.log()');
console.log("Geocoding address: " + address);
console.log("Geocoding failed: " + status);
}
});
}
/*
Other functions
*/
function OnLocalSearch() {
if (gLocalSearch.results[0]) { //This is empty. Why?
var resultLat = gLocalSearch.results[0].lat;
var resultLng = gLocalSearch.results[0].lng;
var point = new GLatLng(resultLat,resultLng);
callbackFunction(point);
}else{
alert("not found!");
}
}
});
//]]>
</script>
가 참고로, 내가 예를 들어이 사용하고 난 이것에 대해 지금 몇 시간 동안 붙어 : http://gmaps-samples-v3.googlecode.com/svn-history/r136/trunk/localsearch/places.html
모든 응답이 크게 감사합니다.
감사합니다, Wenbert 내가 여기 어딘가에 실수를
UPDATE :
또한<script src="http://www.google.com/uds/api?file=uds.js&v=1.0" type="text/javascript"><;/script>
<script src="http://maps.google.com/maps/api/js?v=3.1&sensor=false®ion=PH"></script>
, 당신은 지오 코딩 된 주소를 다시 확인해야합니다. 나는 필리핀 출신이며 Google은 주요 도로 만 지오 코딩하는 것으로 보인다. irc.geekshed.net에서 jgeerdes에 http://gmaps-samples.googlecode.com/svn/trunk/mapcoverage_filtered.html
감사를 #googleapis 참조
어떻게 문자열로 원래의 (정확한) 이름을 얻을 수 있습니까 ..? –