मैं LatLng निर्देशांक में एक पते को जियोकोड करने की कोशिश कर रहा है, लेकिन मैं ऐसा करने में कठिनाई का एक बहुत हो रही है। मैं जानता हूँ कि geocode()एक अतुल्यकालिक समारोह है, और मैं कोई लाभ नहीं हुआ साथ कॉलबैक साथ कर रहा है। मैं इस तरह अन्य पदों को देखकर किया गया है ( कैसे एक अतुल्यकालिक कॉलबैक फ़ंक्शन से मान देने के लिए? ), लेकिन मुझे कठिनाई अवधारणा को समझने आ रही है। किसी को भी मुझे दिखाओ कैसे ठीक है कि कॉलबैक फ़ंक्शन करने के लिए कर सकते हैं, बहुत सराहना की जाएगी। यह एक से अधिक सिर दर्द के बहुत सारे। कॉलबैक एक ऐसा करने के लिए प्राप्त करने में सक्षम था alert()कि सही LatLng देता है, लेकिन स्थिति पैरामीटर सेट नहीं। क्षमा करें उदाहरण पहले उद्धृत से यह पता लगा नहीं कर सका। सुंदर भाषा के लिए नया। तुम मुझे इंगित कर सकते हैं अवधारणा को समझने के लिए किसी भी संदर्भ में भी काफी सराहना कर रहे हैं। धन्यवाद!
var location;
var image;
var map;
var geocoder;
var address;
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(42.763146, -73.3776),
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById(map_canvas),
mapOptions);
var cloudLayer = new google.maps.weather.CloudLayer();
cloudLayer.setMap(map);
addressSet(function(address) {
console.log(address);
// tried to set location = address;, location = new google.maps.LatLng(address);
// neither works
});
addMtsToMap(location,
map,
new google.maps.MarkerImage(img/mts/skier.png, null, null, null, new google.maps.Size(50,50)));
}
function addMtsToMap(location, map, image) {
var marker = new google.maps.Marker({
position: location,
map: map,
icon: image
});
var infoWindow = new google.maps.InfoWindow({content: <h1>Powder!!!</h1>});
google.maps.event.addListener(marker, click, function() {
infoWindow.open(map, marker);
});
}
function addressSet(callback) {
geocoder = new google.maps.Geocoder();
geocoder.geocode({address: Killington+VT}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
address = results[0].geometry.location;
callback(address);
}
});
}













