gmap_coordinates_picker 0.0.13 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -21
- data/app/views/gmap_coordinate_picker/_gmap_coordinate_picker.html.erb +4 -36
- data/app/views/gmap_coordinate_picker/_render_map.html.erb +7 -13
- data/lib/gmap_coordinates_picker/config.rb +0 -2
- data/lib/gmap_coordinates_picker/version.rb +1 -1
- data/lib/gmap_coordinates_picker/view_helper.rb +3 -6
- metadata +17 -19
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -5,11 +5,6 @@ works to provide an easy to use Google Maps interface for displaying and setting
|
|
5
5
|
|
6
6
|
Where a latitude and longitude is set on the model, it is indicated by a marker shown on a Google map centered at the marker. The administrator can change the value of these fields by clicking on the desired new location on the map.
|
7
7
|
|
8
|
-
Demo app source code
|
9
|
-
====================
|
10
|
-
|
11
|
-
https://github.com/amuntasim/gmap-coordicate-picker-demo
|
12
|
-
|
13
8
|
Usage
|
14
9
|
=====
|
15
10
|
|
@@ -22,18 +17,18 @@ gem " gmap_coordinates_picker"
|
|
22
17
|
Then, add in your form:
|
23
18
|
|
24
19
|
```ruby
|
25
|
-
<%= form.gmap_coordinate_picker
|
20
|
+
<%= form.gmap_coordinate_picker :lat_column => 'latitude', :lng_column => 'longitude' , :zoom_level => 10, :default_coordinates => [lat,lng] %>
|
26
21
|
```
|
27
22
|
|
28
23
|
Or, user is as form helper:
|
29
24
|
|
30
25
|
```ruby
|
31
|
-
<%= render_gmap_coordinate_picker
|
26
|
+
<%= render_gmap_coordinate_picker :lat_column => 'latitude', :lng_column => 'longitude' , :zoom_level => 10, :default_coordinates => [lat,lng] %>
|
32
27
|
```
|
33
28
|
To display static map:
|
34
29
|
|
35
30
|
```ruby
|
36
|
-
<%= render_gmap_coordinate_picker
|
31
|
+
<%= render_gmap_coordinate_picker :static => 'true', :zoom_level => 10 , :default_coordinates => [lat,lng] %>
|
37
32
|
```
|
38
33
|
|
39
34
|
|
@@ -45,10 +40,9 @@ beside the option depicted on the example above it can be configured with the fo
|
|
45
40
|
- `map_container_class` - custom class for the map container
|
46
41
|
- `map_width` - default "600px
|
47
42
|
- `map_height` - default "400px"
|
48
|
-
- `api_key` - Google Map api key
|
43
|
+
- `api_key` - Google Map api key (optional)
|
49
44
|
- 'static' - to display only static map, by default it set to false and the map will be editable
|
50
45
|
- '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' }"
|
52
46
|
|
53
47
|
General configuration options
|
54
48
|
=============================
|
@@ -56,15 +50,14 @@ General configuration options
|
|
56
50
|
You can configure the following default values by overriding these values using:
|
57
51
|
GmapCoordinatesPicker.configure method.
|
58
52
|
|
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' }
|
53
|
+
lat_column #= :latitude
|
54
|
+
lng_column #= :longitude
|
55
|
+
default_coordinates #= [23.727666666, 90.410550] #Dhaka (my home town) center point :)
|
56
|
+
map_handler #= 'gMapObj'
|
57
|
+
zoom_level #= 10
|
58
|
+
map_container_class #= 'gmap_coordinate_picker_container'
|
59
|
+
map_width #= '600px'
|
60
|
+
map_height #= '400px'
|
68
61
|
|
69
62
|
There's a handy generator that generates the default configuration file into config/initializers directory.
|
70
63
|
Run the following generator command, then edit the generated file.
|
@@ -75,8 +68,6 @@ rails g gmap_coordinates_picker:config
|
|
75
68
|
|
76
69
|
VERSION
|
77
70
|
=======
|
78
|
-
-0.1.0
|
79
|
-
- Rails4 support
|
80
71
|
|
81
72
|
-0.0.3
|
82
73
|
- `static map` feature added
|
@@ -1,10 +1,8 @@
|
|
1
|
-
|
1
|
+
<%= javascript_include_tag ("http://maps.googleapis.com/maps/api/js?key=#{api_key}&sensor=false") %>
|
2
2
|
<script type="text/javascript">
|
3
3
|
var <%= map_handler%> = <%= map_handler%> || {};
|
4
|
-
var <%= map_handler%>Marker = <%= map_handler%>Marker || {};
|
5
|
-
|
6
|
-
var afterGmapLoaded = function(){
|
7
4
|
|
5
|
+
jQuery(function () {
|
8
6
|
var marker = null;
|
9
7
|
var latlng = new google.maps.LatLng(<%= default_coordinates[0]%>, <%=default_coordinates[1] %>);
|
10
8
|
|
@@ -22,26 +20,12 @@
|
|
22
20
|
position:new google.maps.LatLng(<%= lat_column_value%>,<%=lng_column_value %>),
|
23
21
|
map:map
|
24
22
|
});
|
25
|
-
|
26
|
-
<%= map_handler%>Marker = marker;
|
23
|
+
<% end%>
|
27
24
|
|
28
25
|
google.maps.event.addListener(map, 'click', function(e) {
|
29
26
|
updateLocation(e.latLng);
|
30
27
|
});
|
31
28
|
|
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
|
-
|
45
29
|
function updateLocation(location) {
|
46
30
|
if(marker) {
|
47
31
|
marker.setPosition(location);
|
@@ -51,30 +35,14 @@
|
|
51
35
|
map: map
|
52
36
|
});
|
53
37
|
}
|
54
|
-
<%= map_handler%>Marker = marker;
|
55
38
|
|
56
39
|
map.setCenter(location);
|
57
40
|
jQuery("#<%= lat_dom_id%>").val(location.lat());
|
58
41
|
jQuery("#<%=lng_dom_id %>").val(location.lng());
|
59
42
|
}
|
60
43
|
|
61
|
-
|
62
|
-
}
|
63
|
-
if (typeof window.google == 'undefined' || typeof google.maps == 'undefined'){
|
64
|
-
$.getScript('<%= "http://maps.googleapis.com/maps/api/js?key=#{api_key}" %>', function(){
|
65
|
-
afterGmapLoaded()
|
66
|
-
});
|
67
|
-
}else {
|
68
|
-
afterGmapLoaded();
|
69
|
-
}
|
70
|
-
|
44
|
+
});
|
71
45
|
</script>
|
72
|
-
<% if autocomplete[:enable] %>
|
73
|
-
<div>
|
74
|
-
<input type='text' class='<%= autocomplete[:class] %>' id='searchInput'/>
|
75
|
-
</div>
|
76
|
-
<br/>
|
77
|
-
<% end %>
|
78
46
|
<div class="<%= map_container_class%>" id="<%=map_container%>" style="<%= "width:#{map_width};height:#{map_height}"%>">
|
79
47
|
</div>
|
80
48
|
<%= lat_field%>
|
@@ -1,32 +1,26 @@
|
|
1
|
-
<%= javascript_include_tag ("
|
1
|
+
<%= javascript_include_tag ("http://maps.googleapis.com/maps/api/js?key=#{api_key}&sensor=false") %>
|
2
2
|
<script type="text/javascript">
|
3
3
|
var <%= map_handler%> = <%= map_handler%> || {};
|
4
4
|
|
5
5
|
jQuery(function () {
|
6
6
|
var marker = null;
|
7
|
-
var
|
7
|
+
var latlng = new google.maps.LatLng(<%= default_coordinates[0]%>, <%=default_coordinates[1] %>);
|
8
8
|
|
9
|
-
try {
|
10
|
-
defaultPoint = new google.maps.LatLng(<%= default_coordinates[0]%>, <%=default_coordinates[1] %>);
|
11
|
-
}
|
12
|
-
catch (err) {
|
13
|
-
|
14
|
-
}
|
15
9
|
var myOptions = {
|
16
10
|
zoom: <%=zoom_level %>,
|
17
|
-
center:
|
18
|
-
mapTypeId:
|
11
|
+
center:latlng,
|
12
|
+
mapTypeId:google.maps.MapTypeId.ROADMAP
|
19
13
|
};
|
20
14
|
|
21
15
|
var map = new google.maps.Map(document.getElementById("<%=map_container%>"), myOptions);
|
22
16
|
<%= map_handler%> = map;
|
23
17
|
|
24
18
|
marker = new google.maps.Marker({
|
25
|
-
position:
|
26
|
-
map:
|
19
|
+
position:new google.maps.LatLng(<%= default_coordinates[0]%>,<%=default_coordinates[1] %>),
|
20
|
+
map:map
|
27
21
|
});
|
28
22
|
|
29
23
|
});
|
30
24
|
</script>
|
31
|
-
<div class="<%= map_container_class
|
25
|
+
<div class="<%= map_container_class%>" id="<%=map_container%>" style="<%= "width:#{map_width};height:#{map_height}"%>">
|
32
26
|
</div>
|
@@ -22,7 +22,6 @@ 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
|
26
25
|
end
|
27
26
|
|
28
27
|
configure do |config|
|
@@ -31,7 +30,6 @@ module GmapCoordinatesPicker
|
|
31
30
|
config.default_coordinates = [23.727666666, 90.410550] #Dhaka (my home town) center point :)
|
32
31
|
config.map_handler = 'gMapObj'
|
33
32
|
config.zoom_level = 10
|
34
|
-
config.autocomplete = { enable: false, class: 'form-control'}
|
35
33
|
config.map_container_class = 'gmap_coordinate_picker_container'
|
36
34
|
config.map_width = '600px'
|
37
35
|
config.map_height = '400px'
|
@@ -10,10 +10,9 @@ module GmapCoordinatesPicker #:nodoc
|
|
10
10
|
lat_column = options[:lat_column] || options[:gmap_conf][:lat_column] || GmapCoordinatesPicker.config.lat_column
|
11
11
|
lng_column = options[:lng_column] || options[:gmap_conf][:lng_column] || GmapCoordinatesPicker.config.lng_column
|
12
12
|
default_coordinates = options[:default_coordinates] || GmapCoordinatesPicker.config.default_coordinates
|
13
|
-
lat_column_value = options[:object].present? ? options[:object].send(lat_column)
|
14
|
-
lng_column_value = options[:object].present? ? options[:object].send(lng_column)
|
13
|
+
lat_column_value = options[:object].present? ? options[:object].send(lat_column) : default_coordinates[0]
|
14
|
+
lng_column_value = options[:object].present? ? options[:object].send(lng_column) : default_coordinates[1]
|
15
15
|
prefix = options[:object].present? ? options[:object].class.name.downcase : "gmap_coordinate_picker"
|
16
|
-
autocomplete = options[:autocomplete] || GmapCoordinatesPicker.config.autocomplete
|
17
16
|
lat_dom_id = "#{prefix}_#{lat_column}"
|
18
17
|
lng_dom_id = "#{prefix}_#{lng_column}"
|
19
18
|
end
|
@@ -26,8 +25,7 @@ module GmapCoordinatesPicker #:nodoc
|
|
26
25
|
:map_container_class => options[:map_container_class] || GmapCoordinatesPicker.config.map_container_class,
|
27
26
|
:map_width => options[:map_width] || GmapCoordinatesPicker.config.map_width,
|
28
27
|
:map_height => options[:map_height] || GmapCoordinatesPicker.config.map_height,
|
29
|
-
:
|
30
|
-
:default_coordinates => default_coordinates.empty? ? GmapCoordinatesPicker.config.default_coordinates : options[:default_coordinates],
|
28
|
+
:default_coordinates => options[:default_coordinates] || GmapCoordinatesPicker.config.default_coordinates,
|
31
29
|
}
|
32
30
|
|
33
31
|
editable_map_locals = {
|
@@ -39,7 +37,6 @@ module GmapCoordinatesPicker #:nodoc
|
|
39
37
|
:map_container => "#{prefix}_#{lat_column}_#{lng_column}_container#{Time.now.to_i}",
|
40
38
|
:lat_dom_id => lat_dom_id,
|
41
39
|
:lng_dom_id => lng_dom_id,
|
42
|
-
:autocomplete => autocomplete,
|
43
40
|
:lat_field => lat_lng_field(lat_column, lat_column_value, lat_dom_id, options),
|
44
41
|
:lng_field => lat_lng_field(lng_column, lng_column_value, lng_dom_id, options)
|
45
42
|
}
|
metadata
CHANGED
@@ -1,35 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmap_coordinates_picker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Muntasim Ahmed
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2014-01-28 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rails
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: 3.1.0
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '6'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 3.1.0
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '6'
|
33
30
|
description: It works without any dependency to any third party library
|
34
31
|
email:
|
35
32
|
- ahmed2tul@gmail.com
|
@@ -37,42 +34,43 @@ executables: []
|
|
37
34
|
extensions: []
|
38
35
|
extra_rdoc_files: []
|
39
36
|
files:
|
40
|
-
- MIT-LICENSE
|
41
|
-
- README.md
|
42
|
-
- Rakefile
|
43
37
|
- app/views/gmap_coordinate_picker/_gmap_coordinate_picker.html.erb
|
44
38
|
- app/views/gmap_coordinate_picker/_render_map.html.erb
|
45
39
|
- lib/generators/gmap_coordinates_picker/config_generator.rb
|
46
40
|
- lib/generators/gmap_coordinates_picker/templates/gmap_coordinates_picker_config.rb
|
47
|
-
- lib/gmap_coordinates_picker.rb
|
48
41
|
- lib/gmap_coordinates_picker/config.rb
|
49
42
|
- lib/gmap_coordinates_picker/engine.rb
|
50
43
|
- lib/gmap_coordinates_picker/form_builder.rb
|
51
44
|
- lib/gmap_coordinates_picker/formtastic.rb
|
52
45
|
- lib/gmap_coordinates_picker/version.rb
|
53
46
|
- lib/gmap_coordinates_picker/view_helper.rb
|
47
|
+
- lib/gmap_coordinates_picker.rb
|
48
|
+
- MIT-LICENSE
|
49
|
+
- Rakefile
|
50
|
+
- README.md
|
54
51
|
homepage: ''
|
55
52
|
licenses: []
|
56
|
-
metadata: {}
|
57
53
|
post_install_message:
|
58
54
|
rdoc_options: []
|
59
55
|
require_paths:
|
60
56
|
- lib
|
61
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
62
59
|
requirements:
|
63
|
-
- -
|
60
|
+
- - ! '>='
|
64
61
|
- !ruby/object:Gem::Version
|
65
62
|
version: '0'
|
66
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
67
65
|
requirements:
|
68
|
-
- -
|
66
|
+
- - ! '>='
|
69
67
|
- !ruby/object:Gem::Version
|
70
68
|
version: '0'
|
71
69
|
requirements: []
|
72
70
|
rubyforge_project:
|
73
|
-
rubygems_version:
|
71
|
+
rubygems_version: 1.8.25
|
74
72
|
signing_key:
|
75
|
-
specification_version:
|
73
|
+
specification_version: 3
|
76
74
|
summary: works to provide an easy to use Google Maps interface for displaying and
|
77
75
|
setting geographic co-ordinates
|
78
76
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: b4cfba6571184c20dd751aed25d6c9a385e74650
|
4
|
-
data.tar.gz: 4933899cc88b1558a52113f43f06c3c3f46f0be0
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 914e5d5acc3ef9747638b7ca95331212f1716a0ea40ee24c84c7cab27acd812a12ce5763fc6a28b6ea405fd0475f74d43e5f5950f33f17af345968fec4bfa9f5
|
7
|
-
data.tar.gz: 6b2e9dc1b26996952d484d16b7de45f3dfc72ec011af9428f242082e3ea508973dc36d749650b989aa54eeda05ad21c7cb683d763ff5ab5a6e11ae23092646fd
|