rails_admin_map_field 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -11,65 +11,36 @@ Usage
11
11
  rails_admin_map_field expects that the model will have two attributes, one for latitude and one for longitude of the point represented. To enable rails_admin_map_field, add the following to your `Gemfile`:
12
12
 
13
13
  ```ruby
14
- gem 'rails_admin_map_field', git: 'git://github.com/keitoaino/rails_admin_map_field.git'
14
+ gem 'rails_admin_map_field'
15
15
  ```
16
16
 
17
- Then, add in your `config/initializers/rails_admin.rb` initializer:
17
+ or directly from Github repo:
18
18
 
19
19
  ```ruby
20
- RailsAdmin.config do |config|
21
- config.model User do
22
- edit do
23
- field :latitude, :map
24
- end
25
- end
26
- end
20
+ gem 'rails_admin_map_field', git: 'git://github.com/keitoaino/rails_admin_map_field.git'
27
21
  ```
28
22
 
29
- **Note**: The field which is set as a map-type field must be the latitude field, not the longitude. By default, rails_admin_map_field will guess that the longitude field is called "longitude".
30
-
31
- Configuration
32
- =============
33
-
34
- For different configurations, rails_admin_map_field can be configured with the following:
35
-
36
- - `longitude_field` - the name of the longitude field that forms the the co-ordinate with the latitude field specified. Defaults to "longitude"
37
- - `google_api_key` - if you use a Google Maps API Key, it can be specified here.
38
- - `default_latitude` - the latitude to center the map shown on if the latitude field is blank. Defaults to 51.5, the latitude of London, UK.
39
- - `default_longitude` - the longitude used if the longitude field is blank. Defaults to -0.126, the longitude of London, UK.
40
-
41
- A more complicated configuration example:
23
+ Then, add in your `config/initializers/rails_admin.rb` initializer:
42
24
 
43
25
  ```ruby
44
26
  RailsAdmin.config do |config|
45
- config.model Point do
27
+ config.model User do
46
28
  edit do
47
- field :lat, :map do
48
- longitude_field :lon
49
- google_api_key "a1b2c3d4e5f6deadbeef"
50
- default_latitude -34.0 # Sydney, Australia
51
- default_longitude 151.0
52
- end
29
+ field :address, :map
53
30
  end
54
31
  end
55
32
  end
56
33
  ```
57
34
 
35
+ **Note**: The field which is set as a map-type field must be the address field.
36
+
58
37
  LICENSE
59
38
  =======
60
- rails_admin_map_field is licensed under the MIT license.
39
+ rails_admin_map_field is licensed under the GPLv2 license.
61
40
 
62
41
  Copyright (C) 2011 by Jason Langenauer
63
42
 
64
- Permission is hereby granted, free of charge, to any person obtaining a copy
65
- of this software and associated documentation files (the "Software"), to deal
66
- in the Software without restriction, including without limitation the rights
67
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
68
- copies of the Software, and to permit persons to whom the Software is
69
- furnished to do so, subject to the following conditions:
70
-
71
- The above copyright notice and this permission notice shall be included in
72
- all copies or substantial portions of the Software.
43
+ Copyright (C) 2013 by Keito Aino
73
44
 
74
45
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
75
46
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@@ -10,34 +10,35 @@ mapOptions = {
10
10
  mapTypeId: google.maps.MapTypeId.ROADMAP
11
11
  }
12
12
 
13
- map_element = document.getElementById 'map'
14
- map = new google.maps.Map map_element, mapOptions
13
+ window.onload = ->
14
+ map_element = document.getElementById 'map'
15
+ map = new google.maps.Map map_element, mapOptions
15
16
 
16
- google.maps.event.addListener map, 'click', (event) ->
17
- updateLocation event.latLng
17
+ google.maps.event.addListener map, 'click', (event) ->
18
+ updateLocation event.latLng
18
19
 
19
- updateLocation = (location, center) ->
20
- if marker
21
- marker.setPosition location
22
- else
23
- marker = new google.maps.Marker
24
- position: location,
25
- map: map
20
+ updateLocation = (location, center) ->
21
+ if marker
22
+ marker.setPosition location
23
+ else
24
+ marker = new google.maps.Marker
25
+ position: location,
26
+ map: map
26
27
 
27
- lat.value = location.lat()
28
- lng.value = location.lng()
28
+ lat.value = location.lat()
29
+ lng.value = location.lng()
29
30
 
30
- if center
31
- map.setCenter location
31
+ if center
32
+ map.setCenter location
32
33
 
33
- setInterval ->
34
- google.maps.event.trigger map, 'resize'
35
- , 100
34
+ setInterval ->
35
+ google.maps.event.trigger map, 'resize'
36
+ , 100
36
37
 
37
- address.addEventListener 'keyup', ->
38
- geocoder.geocode {address: this.value}, (results, status) ->
39
- if status == google.maps.GeocoderStatus.OK
40
- updateLocation results[0].geometry.location, true
38
+ address.addEventListener 'keyup', ->
39
+ geocoder.geocode {address: this.value}, (results, status) ->
40
+ if status == google.maps.GeocoderStatus.OK
41
+ updateLocation results[0].geometry.location, true
41
42
 
42
43
 
43
- updateLocation new google.maps.LatLng(lat.value, lng.value), true
44
+ updateLocation new google.maps.LatLng(lat.value, lng.value), true
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
 
14
14
 
15
15
  s.name = "rails_admin_map_field"
16
- s.version = "0.0.3"
16
+ s.version = "0.0.4"
17
17
  s.platform = Gem::Platform::RUBY
18
18
  s.authors = ["Keito Aino"]
19
19
  s.email = ["keitoaino@gmail.com"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_map_field
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-23 00:00:00.000000000 Z
12
+ date: 2013-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise