gmap_coordinates_picker 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4259d3b45eaebeead4a6edffcd5a194b3f0a962
|
4
|
+
data.tar.gz: 941e24634f14dc6dcf0dae79b93765a03f77aca2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eedf22da95eb918dc14c24d322c73c9e2d0fa9f679fb4b2aaafd6a88b0f721e88307e38c60852969941a924f0bf2cb2914e4b5a151db32223d7fe782738834e9
|
7
|
+
data.tar.gz: 1e4cdb6f95727766cb29be5ec8fb934b0fc9b0caabca6cc659c4fe98ee66c2ec56148c107596232dd874f388d8e2b3468f6f7157ea430b73a68378e27f2fb8ce
|
data/README.md
CHANGED
@@ -22,13 +22,13 @@ gem " gmap_coordinates_picker"
|
|
22
22
|
Then, add in your form:
|
23
23
|
|
24
24
|
```ruby
|
25
|
-
<%= form.gmap_coordinate_picker :lat_column => 'latitude', :lng_column => 'longitude' , :zoom_level => 10, :default_coordinates => [lat,lng] %>
|
25
|
+
<%= form.gmap_coordinate_picker :lat_column => 'latitude', :lng_column => 'longitude' , :zoom_level => 10, :default_coordinates => [lat,lng], autocomplete: { enable: true, class: 'form-control' } %>
|
26
26
|
```
|
27
27
|
|
28
28
|
Or, user is as form helper:
|
29
29
|
|
30
30
|
```ruby
|
31
|
-
<%= render_gmap_coordinate_picker :lat_column => 'latitude', :lng_column => 'longitude' , :zoom_level => 10, :default_coordinates => [lat,lng] %>
|
31
|
+
<%= render_gmap_coordinate_picker :lat_column => 'latitude', :lng_column => 'longitude' , :zoom_level => 10, :default_coordinates => [lat,lng], autocomplete: { enable: true, class: 'form-control' } %>
|
32
32
|
```
|
33
33
|
To display static map:
|
34
34
|
|
@@ -48,6 +48,7 @@ beside the option depicted on the example above it can be configured with the fo
|
|
48
48
|
- `api_key` - Google Map api key (optional)
|
49
49
|
- 'static' - to display only static map, by default it set to false and the map will be editable
|
50
50
|
- 'map_handler' - javascript map object to operate custom event on rendered map by default gMapObj is assigned as map object. You can implement any google map API methods like setCenter, zoom with that object
|
51
|
+
- 'autocomplete' - enable autocomplete with input class - default "{ enable: true, class: 'form-control' }"
|
51
52
|
|
52
53
|
General configuration options
|
53
54
|
=============================
|
@@ -55,14 +56,15 @@ General configuration options
|
|
55
56
|
You can configure the following default values by overriding these values using:
|
56
57
|
GmapCoordinatesPicker.configure method.
|
57
58
|
|
58
|
-
lat_column #= :latitude
|
59
|
-
lng_column #= :longitude
|
60
|
-
default_coordinates #= [23.727666666, 90.410550] #Dhaka (my home town) center point :)
|
61
|
-
map_handler #= 'gMapObj'
|
62
|
-
zoom_level #= 10
|
63
|
-
map_container_class #= 'gmap_coordinate_picker_container'
|
64
|
-
map_width #= '600px'
|
65
|
-
map_height #= '400px'
|
59
|
+
lat_column #= :latitude
|
60
|
+
lng_column #= :longitude
|
61
|
+
default_coordinates #= [23.727666666, 90.410550] #Dhaka (my home town) center point :)
|
62
|
+
map_handler #= 'gMapObj'
|
63
|
+
zoom_level #= 10
|
64
|
+
map_container_class #= 'gmap_coordinate_picker_container'
|
65
|
+
map_width #= '600px'
|
66
|
+
map_height #= '400px'
|
67
|
+
autocomplete #= { enable: true, class: 'form-control' }
|
66
68
|
|
67
69
|
There's a handy generator that generates the default configuration file into config/initializers directory.
|
68
70
|
Run the following generator command, then edit the generated file.
|
@@ -75,7 +77,7 @@ VERSION
|
|
75
77
|
=======
|
76
78
|
-0.1.0
|
77
79
|
- Rails4 support
|
78
|
-
|
80
|
+
|
79
81
|
-0.0.3
|
80
82
|
- `static map` feature added
|
81
83
|
- `javascript map handler` support added
|
@@ -1,6 +1,7 @@
|
|
1
|
-
|
1
|
+
<% autocomplete = autocomplete || {} %>
|
2
2
|
<script type="text/javascript">
|
3
3
|
var <%= map_handler%> = <%= map_handler%> || {};
|
4
|
+
var <%= map_handler%>Marker = <%= map_handler%>Marker || {};
|
4
5
|
|
5
6
|
var afterGmapLoaded = function(){
|
6
7
|
|
@@ -22,11 +23,25 @@
|
|
22
23
|
map:map
|
23
24
|
});
|
24
25
|
<% end%>
|
26
|
+
<%= map_handler%>Marker = marker;
|
25
27
|
|
26
28
|
google.maps.event.addListener(map, 'click', function(e) {
|
27
29
|
updateLocation(e.latLng);
|
28
30
|
});
|
29
31
|
|
32
|
+
<% if autocomplete[:enable] %>
|
33
|
+
var input = document.getElementById('searchInput');
|
34
|
+
var autocomplete = new google.maps.places.Autocomplete(input);
|
35
|
+
autocomplete.bindTo('bounds', map);
|
36
|
+
|
37
|
+
autocomplete.addListener('place_changed', function() {
|
38
|
+
var place = autocomplete.getPlace();
|
39
|
+
var location = place.geometry.location;
|
40
|
+
updateLocation(location)
|
41
|
+
return;
|
42
|
+
});
|
43
|
+
<% end %>
|
44
|
+
|
30
45
|
function updateLocation(location) {
|
31
46
|
if(marker) {
|
32
47
|
marker.setPosition(location);
|
@@ -36,6 +51,7 @@
|
|
36
51
|
map: map
|
37
52
|
});
|
38
53
|
}
|
54
|
+
<%= map_handler%>Marker = marker;
|
39
55
|
|
40
56
|
map.setCenter(location);
|
41
57
|
jQuery("#<%= lat_dom_id%>").val(location.lat());
|
@@ -53,6 +69,12 @@
|
|
53
69
|
}
|
54
70
|
|
55
71
|
</script>
|
72
|
+
<% if autocomplete[:enable] %>
|
73
|
+
<div>
|
74
|
+
<input type='text' class='<%= autocomplete[:class] %>' id='searchInput'/>
|
75
|
+
</div>
|
76
|
+
<br/>
|
77
|
+
<% end %>
|
56
78
|
<div class="<%= map_container_class%>" id="<%=map_container%>" style="<%= "width:#{map_width};height:#{map_height}"%>">
|
57
79
|
</div>
|
58
80
|
<%= lat_field%>
|
@@ -22,6 +22,7 @@ module GmapCoordinatesPicker
|
|
22
22
|
config_accessor :map_container_class
|
23
23
|
config_accessor :map_width
|
24
24
|
config_accessor :map_height
|
25
|
+
config_accessor :autocomplete
|
25
26
|
end
|
26
27
|
|
27
28
|
configure do |config|
|
@@ -30,6 +31,7 @@ module GmapCoordinatesPicker
|
|
30
31
|
config.default_coordinates = [23.727666666, 90.410550] #Dhaka (my home town) center point :)
|
31
32
|
config.map_handler = 'gMapObj'
|
32
33
|
config.zoom_level = 10
|
34
|
+
config.autocomplete = { enable: true, class: 'form-control'}
|
33
35
|
config.map_container_class = 'gmap_coordinate_picker_container'
|
34
36
|
config.map_width = '600px'
|
35
37
|
config.map_height = '400px'
|
@@ -13,6 +13,7 @@ module GmapCoordinatesPicker #:nodoc
|
|
13
13
|
lat_column_value = options[:object].present? ? options[:object].send(lat_column) || default_coordinates[0] : default_coordinates[0]
|
14
14
|
lng_column_value = options[:object].present? ? options[:object].send(lng_column) || default_coordinates[1] : default_coordinates[1]
|
15
15
|
prefix = options[:object].present? ? options[:object].class.name.downcase : "gmap_coordinate_picker"
|
16
|
+
autocomplete = options[:autocomplete] || GmapCoordinatesPicker.config.autocomplete
|
16
17
|
lat_dom_id = "#{prefix}_#{lat_column}"
|
17
18
|
lng_dom_id = "#{prefix}_#{lng_column}"
|
18
19
|
end
|
@@ -25,6 +26,7 @@ module GmapCoordinatesPicker #:nodoc
|
|
25
26
|
:map_container_class => options[:map_container_class] || GmapCoordinatesPicker.config.map_container_class,
|
26
27
|
:map_width => options[:map_width] || GmapCoordinatesPicker.config.map_width,
|
27
28
|
:map_height => options[:map_height] || GmapCoordinatesPicker.config.map_height,
|
29
|
+
:autocomplete => options[:autocomplete] || GmapCoordinatesPicker.config.autocomplete,
|
28
30
|
:default_coordinates => options[:default_coordinates].empty? ? GmapCoordinatesPicker.config.default_coordinates : options[:default_coordinates],
|
29
31
|
}
|
30
32
|
|
@@ -37,6 +39,7 @@ module GmapCoordinatesPicker #:nodoc
|
|
37
39
|
:map_container => "#{prefix}_#{lat_column}_#{lng_column}_container#{Time.now.to_i}",
|
38
40
|
:lat_dom_id => lat_dom_id,
|
39
41
|
:lng_dom_id => lng_dom_id,
|
42
|
+
:autocomplete => autocomplete,
|
40
43
|
:lat_field => lat_lng_field(lat_column, lat_column_value, lat_dom_id, options),
|
41
44
|
:lng_field => lat_lng_field(lng_column, lng_column_value, lng_dom_id, options)
|
42
45
|
}
|