activeadmin_latlng 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/activeadmin/views/google_map_proxy.rb +2 -2
- data/lib/activeadmin/views/templates/google.html +30 -3
- data/lib/activeadmin_latlng/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38b4b42f8113d60b1e6f5e770abdef40a6564086
|
4
|
+
data.tar.gz: f76b470fd420f00e8a2ab21fe6feb92b21cdeb65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e60d582e509b317a53fc71ab7cd5119f88d9fbaea73e6e09dd9a257060ee17e4c7cf923461d30c0a61ac4be10915965d35975f3acf2b2386ac69f5ec317594f6
|
7
|
+
data.tar.gz: c98623b9763916d2661644b0e7fdce687c34ee69e7a36688a6b64ee9d5332a3a0facc453c604af8b6df467dd1347868460cb12978cf136ae17b69be5a4c4654d
|
data/README.md
CHANGED
@@ -45,6 +45,12 @@ end
|
|
45
45
|
|
46
46
|
* `api_key_env` - you can send name of ENV-variable where storing API key for map.
|
47
47
|
|
48
|
+
* `default_lat` - default latitude for placemark, Moscow latitude by default.
|
49
|
+
|
50
|
+
* `default_lng` - default longitude for placemark, Moscow longitude by default.
|
51
|
+
|
52
|
+
* `map_zoom` - default zoom for map, `12` by default.
|
53
|
+
|
48
54
|
### Example
|
49
55
|
|
50
56
|
```ruby
|
@@ -6,11 +6,11 @@ module ActiveAdmin
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def loading_map_code
|
9
|
-
@loading_map ? "<script src=\"https://maps.googleapis.com/maps/api/js?language=#{@lang}#{key}&callback=googleMapObject.init\" async defer></script>" : ''
|
9
|
+
@loading_map ? "<script src=\"https://maps.googleapis.com/maps/api/js?language=#{@lang}#{key}&libraries=places&callback=googleMapObject.init\" async defer></script>" : ''
|
10
10
|
end
|
11
11
|
|
12
12
|
def to_s
|
13
|
-
File.open(File.expand_path('../templates/google.html', __FILE__)).read % [loading_map_code, @height, @id_lat, @id_lng, @
|
13
|
+
File.open(File.expand_path('../templates/google.html', __FILE__)).read % [loading_map_code, @height, @id_lat, @id_lng, @map_zoom, @default_lat, @default_lng]
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -8,6 +8,7 @@
|
|
8
8
|
coords: null,
|
9
9
|
map: null,
|
10
10
|
marker: null,
|
11
|
+
zoom: %d,
|
11
12
|
|
12
13
|
getCoordinates: function() {
|
13
14
|
return {
|
@@ -27,25 +28,51 @@
|
|
27
28
|
|
28
29
|
googleMapObject.map = new google.maps.Map(document.getElementById('google_map'), {
|
29
30
|
center: googleMapObject.coords,
|
30
|
-
zoom:
|
31
|
+
zoom: googleMapObject.zoom
|
31
32
|
});
|
32
|
-
|
33
|
+
|
33
34
|
var latLngCoord = new google.maps.LatLng(googleMapObject.coords.lat, googleMapObject.coords.lng);
|
34
35
|
googleMapObject.marker = new google.maps.Marker({
|
35
36
|
position: latLngCoord,
|
36
37
|
map: googleMapObject.map,
|
37
38
|
draggable: true
|
38
39
|
});
|
40
|
+
|
39
41
|
googleMapObject.map.addListener('click', function(e) {
|
40
42
|
googleMapObject.coords = { lat: e.latLng.lat(), lng: e.latLng.lng() };
|
41
43
|
googleMapObject.saveCoordinates();
|
42
44
|
googleMapObject.marker.setPosition(googleMapObject.coords);
|
43
45
|
});
|
46
|
+
|
44
47
|
googleMapObject.marker.addListener('drag', function(e) {
|
45
48
|
googleMapObject.coords = { lat: e.latLng.lat(), lng: e.latLng.lng() };
|
46
49
|
googleMapObject.saveCoordinates();
|
47
50
|
});
|
51
|
+
|
52
|
+
var searchBox = new google.maps.places.SearchBox(document.getElementById('latlng-search-box'));
|
53
|
+
|
54
|
+
googleMapObject.map.controls[google.maps.ControlPosition.TOP_CENTER].push(document.getElementById('latlng-search-box'));
|
55
|
+
|
56
|
+
google.maps.event.addListener(searchBox, 'places_changed', function() {
|
57
|
+
searchBox.set('map', null);
|
58
|
+
|
59
|
+
var bounds = new google.maps.LatLngBounds();
|
60
|
+
|
61
|
+
var place = searchBox.getPlaces()[0];
|
62
|
+
var location = place.geometry.location;
|
63
|
+
|
64
|
+
googleMapObject.coords = { lat: location.lat(), lng: location.lng() };
|
65
|
+
googleMapObject.saveCoordinates();
|
66
|
+
|
67
|
+
googleMapObject.marker.setPosition(location);
|
68
|
+
bounds.extend(location);
|
69
|
+
|
70
|
+
googleMapObject.map.fitBounds(bounds);
|
71
|
+
searchBox.set('map', googleMapObject.map);
|
72
|
+
googleMapObject.map.setZoom(googleMapObject.zoom);
|
73
|
+
});
|
48
74
|
}
|
49
75
|
}
|
50
76
|
</script>
|
51
|
-
|
77
|
+
<input id="latlng-search-box" type="text" style="margin-top: 10px; height: 18px;" placeholder="Search Google Maps...">
|
78
|
+
</li>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin_latlng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Krylov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|