I want to create a geocoder function, which write the result to it's parameter.
function geoCode(latlng,div) {
gc.geocode({'latLng': latlng}, function (result, status) {
if (status == google.maps.GeocoderStatus.OK) {
new google.maps.Marker({
position: result[0].ge开发者_开发知识库ometry.location,
map: map
});
$(div).html(result[0].formatted_address);
}
});
How can I add the div parameter to the geocoder function?
Like this:
gc.geocode({'latLng': latlng, writeHere: div}, function (result, status) {
...
$(writeHere).html(result[0].formatted_address);
}
But it's doesn't working.
Any help would be appreciated.
Try with this:
function geoCode(latlng, div) {
var $div = jq(div);
gc.geocode({
'latLng': latlng
}, function(result, status) {
if (status == google.maps.GeocoderStatus.OK) {
new google.maps.Marker({
position: result[0].geometry.location,
map: map
});
$div.html(result[0].formatted_address);
}
});
}
精彩评论