在创建谷歌地图时获取国家名称以实时更新国家名称字段的最佳方法是什么?
我用这段代码创建了我的谷歌地图:
function createMap(address,distance){
address=$("#settingMeetingPrefs_meeting_city").val();
distance=$("#settingMeetingPrefs_meeting_distance").val();
var geocoder = new google.maps.Geocoder();
if (address == null)
var address = "{{city}}";
else
var address = address;
if (distance==null)
distance= "{{distance}}";
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
var latlng = new google.maps.LatLng(latitude, longitude);
var myOptions = {
zoom: 7,
center: latlng,
scrollwheel: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map
});
// Add circle overlay and bind to marker
var circle = new google.maps.Circle({
map: map,
radius: distance * 1000 ,
// radius: document.getElementById('distance').value * 1000 , // 10 miles in metres
fillColor: '#0000FF'
});
circle.bindTo('center', marker, 'position');
}
});
}