I'm trying to place a marker on my map and then use the position of that marker to draw some polygons. However, marker.getPosition() does not seem to return a value initially. I would need to call the function again to get the previous marker position. Does anyone have any suggestions as to why this is
function codeAddress() {
var address = fubar;
geocoder.geocode( { 'address': address}, function(results, status) {
map.setCenter(results[0].geometry.location);
map.setZoom(1);
if (marker == null){
marker = new google.maps.Marker({
map: map,
});
}
marker.setPosition(results[0].geometry.location);
});
document.write(marker.getPosition()); //this displays nothing
}