Skip to content

Commit

Permalink
Add google maps options and rendered callback
Browse files Browse the repository at this point in the history
  • Loading branch information
mpowaga committed Jan 16, 2015
1 parent 29c2bfc commit 83d9511
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ Schemas.Cities = new SimpleSchema

*autolocate* if set to `true` will automatically ask for user's location. Defaults to `false`

*googleMap* google maps specific [options](https://developers.google.com/maps/documentation/javascript/reference#MapOptions).

*rendered* function called when map is rendered. [google.maps.Map](https://developers.google.com/maps/documentation/javascript/reference#Map) will be passed as an argument.

```
location:
type: String
Expand Down
8 changes: 7 additions & 1 deletion lib/client/autoform-map.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ Template.afMap.rendered = ->
zoom: 0
mapTypeId: google.maps.MapTypeId[@data.options.mapType]
streetViewControl: false


if @data.atts.googleMap
_.extend mapOptions, @data.atts.googleMap

@data.map = new google.maps.Map @find('.js-map'), mapOptions

if @data.value
Expand Down Expand Up @@ -72,6 +75,9 @@ Template.afMap.rendered = ->
@data.setMarker @data.map, location, @data.options.zoom
@data.map.setCenter location

if typeof @data.atts.rendered == 'function'
@data.atts.rendered @data.map

google.maps.event.addListener @data.map, 'click', (e) =>
@data.setMarker @data.map, e.latLng

Expand Down

0 comments on commit 83d9511

Please sign in to comment.