1. Home >
  2. Documentation >
  3. Services >
  4. getaddress
 

getaddress

This function retrieves a google.maps.GeocoderResult from a latLng.

Usage

Parameters

Example

This example show an InfoWindow with the address result of the marker. The InfoWindow will appear when the marker is relocated on the map (drag & drop the marker).

$("#test").gmap3({
  marker:{
    latLng: [46.578498,2.457275],
    options:{
      draggable:true
    },
    events:{
      dragend: function(marker){
        $(this).gmap3({
          getaddress:{
            latLng:marker.getPosition(),
            callback:function(results){
              var map = $(this).gmap3("get"),
                infowindow = $(this).gmap3({get:"infowindow"}),
                content = results && results[1] ? results && results[1].formatted_address : "no address";
              if (infowindow){
                infowindow.open(map, marker);
                infowindow.setContent(content);
              } else {
                $(this).gmap3({
                  infowindow:{
                    anchor:marker, 
                    options:{content: content}
                  }
                });
              }
            }
          }
        });
      }
    }
  },
  map:{
    options:{
      zoom: 5
    }
  }
});
Close