jekyll-maps 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +4 -0
- data/jekyll-maps.gemspec +1 -1
- data/lib/jekyll-maps/google_map_api.js +123 -124
- data/lib/jekyll-maps/google_map_api.rb +1 -1
- data/lib/jekyll-maps/google_map_tag.rb +9 -5
- data/lib/jekyll-maps/options_parser.rb +1 -0
- data/lib/jekyll-maps/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bf3fffa8b6a67a476bdbe5fc43b4448098bb365
|
4
|
+
data.tar.gz: a2907b6e1a100ed5ed7d66bdbfcd2278b2316127
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a326efc82dd3efa73f3c140137c0f87f29f86e93d8d795883cd4a83f57d7064ee8868e3e250932c04cda356fa784eada946ea9ba612ad9a85c107a8d5dfcaf38
|
7
|
+
data.tar.gz: f7bb0962ad9a89794a2c767b88a92870bb995048b313c678e92fe8ed71fd7bb8672ca3dee3b14bdefbfab2168a9929f903b3473b9e7575b6c8581ca1d125b612
|
data/History.md
CHANGED
data/jekyll-maps.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.authors = ["Anatoliy Yastreb"]
|
12
12
|
spec.email = ["anatoliy.yastreb@gmail.com"]
|
13
13
|
|
14
|
-
spec.homepage = "https://github.com/ayastreb/jekyll-
|
14
|
+
spec.homepage = "https://github.com/ayastreb/jekyll-maps"
|
15
15
|
spec.licenses = ["MIT"]
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
|
17
17
|
spec.require_paths = ["lib"]
|
@@ -1,136 +1,135 @@
|
|
1
|
+
/* global google */
|
2
|
+
/* global MarkerClusterer */
|
3
|
+
// eslint-disable-next-line no-unused-vars
|
1
4
|
var jekyllMaps = (function () {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
this.mapReady = true;
|
24
|
-
this.render();
|
5
|
+
'use strict'
|
6
|
+
var clusterSettings = {}
|
7
|
+
var clusterReady = false
|
8
|
+
var mapReady = false
|
9
|
+
var options = {}
|
10
|
+
var data = []
|
11
|
+
var maps = []
|
12
|
+
|
13
|
+
return {
|
14
|
+
initializeMap: initializeMap,
|
15
|
+
initializeCluster: initializeCluster,
|
16
|
+
register: register
|
17
|
+
}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Setup Google Maps options and call renderer.
|
21
|
+
*/
|
22
|
+
function initializeMap () {
|
23
|
+
options = {
|
24
|
+
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
25
|
+
center: new google.maps.LatLng(0, 0)
|
25
26
|
}
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
27
|
+
mapReady = true
|
28
|
+
render()
|
29
|
+
}
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Register map data to be rendered once Google Maps API is loaded.
|
33
|
+
*
|
34
|
+
* @param string id
|
35
|
+
* @param Array locations
|
36
|
+
* @param Object settings
|
37
|
+
*/
|
38
|
+
function register (id, locations, options) {
|
39
|
+
data.push({ id: id, locations: locations, options: options })
|
40
|
+
render()
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Render maps data if Google Maps API is loaded.
|
45
|
+
*/
|
46
|
+
function render () {
|
47
|
+
if (!mapReady) return
|
48
|
+
|
49
|
+
while (data.length > 0) {
|
50
|
+
var item = data.pop()
|
51
|
+
var bounds = new google.maps.LatLngBounds()
|
52
|
+
var mapOptions = Object.assign({}, options, item.options)
|
53
|
+
var map = new google.maps.Map(document.getElementById(item.id), mapOptions)
|
54
|
+
var infoWindow = new google.maps.InfoWindow()
|
55
|
+
var markers = item.locations.map(createMarker)
|
56
|
+
|
57
|
+
map.fitBounds(bounds)
|
58
|
+
google.maps.event.addListenerOnce(map, 'bounds_changed', function() {
|
59
|
+
if (this.customZoom) this.setZoom(this.customZoom)
|
60
|
+
})
|
61
|
+
if (mapOptions.useCluster) {
|
62
|
+
maps.push({ map: map, markers: markers })
|
63
|
+
processCluster()
|
64
|
+
}
|
37
65
|
}
|
38
66
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
options = Object.assign({}, this.options, data.settings),
|
49
|
-
map = new google.maps.Map(document.getElementById(data.id), options),
|
50
|
-
infoWindow = new google.maps.InfoWindow(),
|
51
|
-
markers = data.locations.map(function (location) {
|
52
|
-
return createMarker(location, options.showMarkerPopup);
|
53
|
-
});
|
67
|
+
function createMarker (location) {
|
68
|
+
var position = new google.maps.LatLng(location.latitude, location.longitude)
|
69
|
+
var marker = new google.maps.Marker({
|
70
|
+
position: position,
|
71
|
+
title: location.title,
|
72
|
+
image: location.image,
|
73
|
+
url: location.url,
|
74
|
+
map: map
|
75
|
+
})
|
54
76
|
|
55
|
-
|
56
|
-
|
57
|
-
if (options.useCluster) {
|
58
|
-
this.maps.push({map: map, markers: markers});
|
59
|
-
this.processCluster();
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
function createMarker(location, showMarkerPopup) {
|
64
|
-
var position = new google.maps.LatLng(location.latitude, location.longitude),
|
65
|
-
marker = new google.maps.Marker({
|
66
|
-
position: position,
|
67
|
-
title: location.title,
|
68
|
-
image: location.image,
|
69
|
-
url: location.url,
|
70
|
-
map: map
|
71
|
-
});
|
72
|
-
|
73
|
-
bounds.extend(position);
|
74
|
-
if (showMarkerPopup) marker.addListener('click', markerPopup);
|
75
|
-
|
76
|
-
return marker;
|
77
|
-
}
|
77
|
+
bounds.extend(position)
|
78
|
+
if (mapOptions.showMarkerPopup) marker.addListener('click', markerPopup)
|
78
79
|
|
79
|
-
|
80
|
-
var contentString = '<div class="map-info-window"><h5>' + this.title + '</h5>',
|
81
|
-
link = 'View';
|
82
|
-
if (this.image.length > 0) {
|
83
|
-
link = '<img src="' + this.image + '" alt="' + this.title + '"/>';
|
84
|
-
}
|
85
|
-
contentString += '<a href="' + this.url + '">' + link + '</a></div>';
|
86
|
-
infoWindow.setContent(contentString);
|
87
|
-
infoWindow.open(map, this);
|
88
|
-
}
|
89
|
-
|
90
|
-
function onBoundsChanged() {
|
91
|
-
if (this.getZoom() > options.zoom) {
|
92
|
-
this.setZoom(options.zoom);
|
93
|
-
}
|
94
|
-
}
|
80
|
+
return marker
|
95
81
|
}
|
96
82
|
|
97
|
-
function
|
98
|
-
|
99
|
-
|
100
|
-
|
83
|
+
function markerPopup () {
|
84
|
+
var contentString = '<div class="map-info-window"><h5>' + this.title + '</h5>'
|
85
|
+
var link = 'View'
|
86
|
+
if (this.image.length > 0) {
|
87
|
+
link = '<img src="' + this.image + '" alt="' + this.title + '"/>'
|
88
|
+
}
|
89
|
+
contentString += '<a href="' + this.url + '">' + link + '</a></div>'
|
90
|
+
infoWindow.setContent(contentString)
|
91
|
+
infoWindow.open(map, this)
|
101
92
|
}
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
93
|
+
}
|
94
|
+
|
95
|
+
function initializeCluster (settings) {
|
96
|
+
clusterReady = true
|
97
|
+
clusterSettings = settings || {}
|
98
|
+
processCluster()
|
99
|
+
}
|
100
|
+
|
101
|
+
function processCluster () {
|
102
|
+
if (!clusterReady) return
|
103
|
+
|
104
|
+
while (maps.length > 0) {
|
105
|
+
var obj = maps.pop()
|
106
|
+
// eslint-disable-next-line no-new
|
107
|
+
new MarkerClusterer(obj.map, obj.markers, {
|
108
|
+
gridSize: clusterSettings.grid_size || 25,
|
109
|
+
imagePath: 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m'
|
110
|
+
})
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}())
|
114
|
+
/* Object.assign polyfill */
|
115
|
+
if (typeof Object.assign !== 'function') {
|
116
|
+
Object.assign = function (target) {
|
117
|
+
'use strict'
|
118
|
+
if (target == null) {
|
119
|
+
throw new TypeError('Cannot convert undefined or null to object')
|
113
120
|
}
|
114
121
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
if (source != null) {
|
126
|
-
for (var key in source) {
|
127
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
128
|
-
target[key] = source[key];
|
129
|
-
}
|
130
|
-
}
|
131
|
-
}
|
132
|
-
}
|
133
|
-
return target;
|
134
|
-
};
|
122
|
+
target = Object(target)
|
123
|
+
for (var index = 1; index < arguments.length; index++) {
|
124
|
+
var source = arguments[ index ]
|
125
|
+
if (source != null) {
|
126
|
+
for (var key in source) {
|
127
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
128
|
+
target[ key ] = source[ key ]
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
135
132
|
}
|
136
|
-
|
133
|
+
return target
|
134
|
+
}
|
135
|
+
}
|
@@ -21,7 +21,7 @@ module Jekyll
|
|
21
21
|
#{JS_LIB_NAME}.register(
|
22
22
|
'#{@args[:attributes][:id]}',
|
23
23
|
#{locations.to_json},
|
24
|
-
#{
|
24
|
+
#{map_options.to_json}
|
25
25
|
);
|
26
26
|
</script>
|
27
27
|
HTML
|
@@ -53,11 +53,15 @@ HTML
|
|
53
53
|
end
|
54
54
|
|
55
55
|
private
|
56
|
-
def
|
57
|
-
{
|
58
|
-
useCluster
|
59
|
-
showMarkerPopup
|
56
|
+
def map_options
|
57
|
+
opts = {
|
58
|
+
:useCluster => !@args[:flags][:no_cluster],
|
59
|
+
:showMarkerPopup => @args[:attributes][:show_popup] != "false"
|
60
60
|
}
|
61
|
+
if @args[:attributes][:zoom]
|
62
|
+
opts[:customZoom] = @args[:attributes][:zoom].to_i
|
63
|
+
end
|
64
|
+
opts
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
data/lib/jekyll-maps/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-maps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anatoliy Yastreb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -92,7 +92,7 @@ files:
|
|
92
92
|
- lib/jekyll-maps/version.rb
|
93
93
|
- script/bootstrap
|
94
94
|
- script/cibuild
|
95
|
-
homepage: https://github.com/ayastreb/jekyll-
|
95
|
+
homepage: https://github.com/ayastreb/jekyll-maps
|
96
96
|
licenses:
|
97
97
|
- MIT
|
98
98
|
metadata: {}
|