-1
// this function search location and show on map
function showAddressTextBox(address) { // showAddressTextBox function search location and show on map
// alert(address);
var infowindow2 = new google.maps.InfoWindow(); //this infowindows
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
'address': address
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
google.maps.event.addListener(marker, 'click', function() {
infowindow2.setContent('<div><strong>Address:' + results[0].formatted_address + '</strong><br>' +
'Place ID: ' + results[0].place_id + '</div>');
infowindow2.open(map, marker);
});
// path = address;
// lat = results[0].geometry.location.lat();
// lon = results[0].geometry.location.lng();
} else {
//alert("Geocode was not successful for the following reason: " + status);
}
});
} //end function
VAR지도; function initialize() { var latlng = new google.maps.LatLng (21.15, 79.04); var myOptions = { 줌 : 8, 센터 : latlng, mapTypeId : google.maps.MapTypeId.ROADMAP}}; var map = new google.maps.Map (document.getElementById ("map-canvas"), myOptions); } google.maps.event.addDomListener (window, "load", initialize); 이건 내 코드지만 map.setCenter (results [0] .geometry.location); 이 줄은 오직 –
오류 수정 코드를 주석에 붙여 넣기보다는 업데이트해야합니다. 정말 읽기가 어렵습니다. – SeanKendle
또한 jsfiddle를 만드는 것을 고려하십시오. – SeanKendle