Skip to content

Instantly share code, notes, and snippets.

@ivanvanderbyl
Created August 5, 2012 03:22
Show Gist options
  • Save ivanvanderbyl/3261392 to your computer and use it in GitHub Desktop.
Save ivanvanderbyl/3261392 to your computer and use it in GitHub Desktop.
= address.input :formatted_address,
:label => "Address",
:placeholder => "e.g. Level 1, 41 Stewart Street, Somewhere, Victoria 3012",
:input_html => {:class => "location input-xlarge"}
= javascript_include_tag "//maps.googleapis.com/maps/api/js?sensor=true"
:coffeescript
geocoder = new google.maps.Geocoder()
$("input.location").typeahead(
minLength: 5,
items: 3,
matcher: (query) ->
true
source: (query, process) ->
geocoder.geocode(
'address': query,
'region': 'au',
'bounds': new google.maps.LatLngBounds(new google.maps.LatLng(-47.279229,109.6582), new google.maps.LatLng(-9.275622,156.591793)),
, (results, status) ->
if results?
process $.map results, (item) ->
item.formatted_address
else
process []
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment