Skip to content

Commit

Permalink
allow array [Number]
Browse files Browse the repository at this point in the history
  • Loading branch information
HazemKhaled committed Jun 9, 2015
1 parent cdd0930 commit 49c906b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/client/autoform-map.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ AutoForm.addInputType 'map',
"#{value.lng},#{value.lat}"
else
"#{value.lat},#{value.lng}"
numberArray: (value) ->
[value.lng, value.lat]

Template.afMap.created = ->
GoogleMaps.load(libraries: 'places')
Expand Down Expand Up @@ -60,7 +62,7 @@ initTemplateAndGoogleMaps = ->
@data.map = new google.maps.Map @find('.js-map'), mapOptions

if @data.value
location = if typeof @data.value == 'string' then @data.value.split ',' else [@data.value.lat, @data.value.lng]
location = if typeof @data.value == 'string' then @data.value.split ',' else if typeof @data.value == 'Array' then [@data.value.lat, @data.value.lng] else [@data.value[1],@data.value[0]]
location = new google.maps.LatLng parseFloat(location[0]), parseFloat(location[1])
@data.setMarker @data.map, location, @data.options.zoom
@data.map.setCenter location
Expand Down

0 comments on commit 49c906b

Please sign in to comment.