geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
},
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map-container"),
myOptions);
if (geocoder) {
geocoder.geocode({
'address': address
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
map.setCenter(results[0].geometry.location);
mlat = results[0].geometry.location.lat();
mlng = results[0].geometry.location.lng();
var infowindow = new google.maps.InfoWindow({
content: '<b>You are here</b>',
size: new google.maps.Size(150, 50)
});
var marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title: "You are here"
});
addInfoWindow(marker, "You are here");
checkRange(mlat, mlng);
} else {
alert("No results found");
}
} else {
alert("Geocode was not successful for the following reason: " +
status);
}
});
这是我的谷歌地图代码。我正在使用地理编码器请告诉我如何才能获得城市和地区。我能够获得拉特和土地,但我试图找到城市和地区。