开发者

Add a parameter to a google maps geocoder function

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);
        }
    });
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜