Javascript 不带地图的点击事件地理缓存
我正在做一个MVC asp.net项目。在第1页,我需要发布长坐标和纬度坐标(用户地址),这样服务器就可以返回正确的信息,显示在第2页的谷歌地图上 我在第2页使用Google Map Javascript API V3,我希望在第1页使用它 我正在使用这段代码…有时有效,有时无效。它通常在调试模式下工作。我猜是时间问题。我想不出来Javascript 不带地图的点击事件地理缓存,javascript,google-maps-api-3,geocoding,Javascript,Google Maps Api 3,Geocoding,我正在做一个MVC asp.net项目。在第1页,我需要发布长坐标和纬度坐标(用户地址),这样服务器就可以返回正确的信息,显示在第2页的谷歌地图上 我在第2页使用Google Map Javascript API V3,我希望在第1页使用它 我正在使用这段代码…有时有效,有时无效。它通常在调试模式下工作。我猜是时间问题。我想不出来 google.maps.event.addDomListener(window, 'load', initialize); function initi
google.maps.event.addDomListener(window, 'load', initialize);
function initialize() {
geocoder = new google.maps.Geocoder();
}
function submitClick() {
var address = "Amsterdam, Netherlands";
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();
alert(lat + " and " + lng)
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
我对谷歌地图api还是新手,所以我认为我只是用错了方法。谢谢你的帮助。这是个时间问题。该页面试图在谷歌回来之前发布。现在,当google回来时,我用javascript发布页面