Skip to content

Commit

Permalink
Add reverse option. Fixes #20
Browse files Browse the repository at this point in the history
  • Loading branch information
mpowaga committed Apr 1, 2015
1 parent dfced11 commit 40035fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Schemas.Cities = new SimpleSchema

*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.

*reverse* if set to `true` lat.lng will be reversed to lng.lat. Works only with strings.

```
location:
type: String
Expand Down
5 changes: 4 additions & 1 deletion lib/client/autoform-map.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ AutoForm.addInputType 'map',
ctx
valueConverters:
string: (value) ->
"#{value.lat},#{value.lng}"
if @attr('reverse')
"#{value.lng},#{value.lat}"
else
"#{value.lat},#{value.lng}"

Template.afMap.rendered = ->
@data.options = _.extend {}, defaults, @data.atts
Expand Down
2 changes: 1 addition & 1 deletion lib/client/autoform-map.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template name="afMap">
<div data-schema-key="{{schemaKey}}">
<div data-schema-key="{{schemaKey}}" reverse="{{atts.reverse}}">
<input type="text" class="js-lat" style="display: none">
<input type="text" class="js-lng" style="display: none">
<input type="text" class="controls af-map-search-box js-search af-map-search-box-hidden">
Expand Down

0 comments on commit 40035fa

Please sign in to comment.