kmz_compressor 2.0.9 → 2.0.10
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: 22764bfbcf300cc16f3a91cf77ad61db40401293
|
4
|
+
data.tar.gz: 356096d49bbc8de00898e36759242376859230db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9d982f62b06c2e760e3219c2edefcda8a3850b3d98de26f042e951ca918f93381d186def9c9f29b8c4e34b7410123109a3ef86daf8894d684e9c9aea2f0a275
|
7
|
+
data.tar.gz: bf93ed0dec8c85c2515c1916dc2aeaf81dbe9d5d45828cc5a3e0c9e19ac6dbd7d8022292153e5423f63444e8c4147773256a08760686f890fcb05000c50a0b0a
|
@@ -7,6 +7,7 @@ window.MapLayerManager = function(map){
|
|
7
7
|
var layerLoadedEventName = 'map:layerLoaded'
|
8
8
|
var layerRemovedEventName = 'map:layerRemoved'
|
9
9
|
var layerHiddenEventName = 'map:layerHidden'
|
10
|
+
var layerClickedEventName = 'map:layerClicked'
|
10
11
|
|
11
12
|
// Prime the KMZ cache on the server before unleashing google's many tilemills
|
12
13
|
function cacheAndLoadKMLLayer(kmlURL, layerName, options) {
|
@@ -37,14 +38,12 @@ window.MapLayerManager = function(map){
|
|
37
38
|
sweep();
|
38
39
|
});
|
39
40
|
|
40
|
-
// Add a listener to catch clicks and close all info windows on other layers
|
41
41
|
google.maps.event.addListener(kmlLayer, 'click', function(){
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
})
|
42
|
+
// Add a listener to catch clicks and close all info windows on other layers
|
43
|
+
closeInfowindowsExcept(layerName)
|
44
|
+
|
45
|
+
// Create a bubbling event when a layer is clicked
|
46
|
+
$(map.getDiv()).trigger({type: layerClickedEventName, layer:layer})
|
48
47
|
});
|
49
48
|
}
|
50
49
|
|
@@ -166,76 +165,95 @@ window.MapLayerManager = function(map){
|
|
166
165
|
});
|
167
166
|
}
|
168
167
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
168
|
+
function removeLayers(){
|
169
|
+
everyLayer(function(layer){
|
170
|
+
removeLayer(layer.name);
|
171
|
+
})
|
172
|
+
}
|
173
|
+
function everyLayer(fn){
|
174
|
+
// NOTE: We use an iterator instead of a for loop because modifications to layers that occur during iteration can mess us up
|
175
|
+
// e.g. if we're responding to an event during the loop and the event adds a layer, we may end up re-iterating on a layer we've already processed
|
176
|
+
$.each(layers.slice(0), function(index, layer){
|
177
|
+
fn(layer, index);
|
178
|
+
})
|
179
|
+
}
|
181
180
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
181
|
+
// Keep layers synced with their state
|
182
|
+
function sweep(){
|
183
|
+
var foundLayers = [];
|
184
|
+
everyLayer(function(layer, index){
|
185
|
+
var kmlStatus = layer.kml ? layer.kml.getStatus() : null;
|
186
|
+
|
187
|
+
// If the layer just finished loading
|
188
|
+
if (!layer.loaded && kmlStatus) {
|
189
|
+
loadingCount--
|
190
|
+
layer.loaded = true
|
191
|
+
layer.error = kmlStatus == 'OK' ? null : kmlStatus // if there were any errors, record them
|
192
|
+
$(map.getDiv()).trigger({type: layerLoadedEventName, layer:layer})
|
193
|
+
}
|
194
|
+
|
195
|
+
// A layer should be hidden, but the kml is showing, hide it (i.e. correct layers that were hidden before the kml was loaded)
|
196
|
+
if (layer.hidden && layer.loaded && layer.kml.getMap()){
|
197
|
+
hideLayer(layer.name)
|
198
|
+
}
|
199
|
+
|
200
|
+
// Remove old layers
|
201
|
+
// Sweep through layers from the newest to oldest, if a layer name is seen more than once, delete all but the newest
|
202
|
+
// Don't delete an instance if we haven't yet seen a version of it with status 'OK'
|
203
|
+
if ($.inArray(layer.name, foundLayers) > -1){
|
204
|
+
layer.kml.setMap(null);
|
205
|
+
layers.splice(index, 1);
|
206
|
+
} else if (layer.loaded) {
|
207
|
+
foundLayers.push(layer.name)
|
208
|
+
}
|
209
|
+
})
|
210
|
+
}
|
211
|
+
|
212
|
+
// Replace spaces with pluses so we don't have problems with some things turning them into %20s and some not
|
213
|
+
// Matches the middleware process
|
214
|
+
function sanitizeURI(uri){
|
215
|
+
var url = $('<a href="' + uri + '"/>')[0]
|
216
|
+
var pathname = decodeURI(url.pathname).trim().replace(/^\/\//, '/') // IE will return a path name with a leading double slash, so ensure it's only a single slash
|
217
|
+
var search = decodeURIComponent(url.search.replace(/\+/g, '%20')).trim().replace(/^\?/, '') // Ensure all "plus spaces" are hex encoded spaces
|
212
218
|
|
213
|
-
|
214
|
-
// Matches the middleware process
|
215
|
-
function sanitizeURI(uri){
|
216
|
-
var url = $('<a href="' + uri + '"/>')[0]
|
217
|
-
var pathname = decodeURI(url.pathname).trim().replace(/^\/\//, '/') // IE will return a path name with a leading double slash, so ensure it's only a single slash
|
218
|
-
var search = decodeURIComponent(url.search.replace(/\+/g, '%20')).trim().replace(/^\?/, '') // Ensure all "plus spaces" are hex encoded spaces
|
219
|
+
output = pathname
|
219
220
|
|
220
|
-
|
221
|
+
if (search !== ''){
|
222
|
+
output += '?'
|
223
|
+
}
|
224
|
+
|
225
|
+
// Encode the individual uri components
|
226
|
+
output += $.map(search.split('&'), function(component){
|
227
|
+
return $.map(component.split('='), function(kv){
|
228
|
+
// HACK: Firefox 'helps' us out by encoding apostrophes as %27 in AJAX requests, However its encodeURIcomponent method
|
229
|
+
// does not. This difference causes a mismatch between the url we use to calculate the cache path in the browser
|
230
|
+
// and on the server. This hack undoes the damage. See https://bugzilla.mozilla.org/show_bug.cgi?id=407172
|
231
|
+
return encodeURIComponent(kv).replace(/'/g, '%27')
|
232
|
+
}).join('=')
|
233
|
+
}).join('&')
|
234
|
+
|
235
|
+
return url.protocol + '//' + url.host + output
|
236
|
+
}
|
221
237
|
|
222
|
-
|
223
|
-
|
238
|
+
function closeInfowindowsExcept(layerName){
|
239
|
+
everyLayer(function(layer){
|
240
|
+
if (layer.name != layerName){
|
241
|
+
closeInfowindow(layer)
|
224
242
|
}
|
243
|
+
})
|
244
|
+
}
|
225
245
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
// and on the server. This hack undoes the damage. See https://bugzilla.mozilla.org/show_bug.cgi?id=407172
|
232
|
-
return encodeURIComponent(kv).replace(/'/g, '%27')
|
233
|
-
}).join('=')
|
234
|
-
}).join('&')
|
235
|
-
|
236
|
-
return url.protocol + '//' + url.host + output
|
237
|
-
}
|
246
|
+
function closeInfowindows(){
|
247
|
+
everyLayer(function(layer){
|
248
|
+
closeInfowindow(layer)
|
249
|
+
})
|
250
|
+
}
|
238
251
|
|
252
|
+
function closeInfowindow(layer){
|
253
|
+
// Close info window by toggling the suppressInfoWindow setting (ensuring it retains its original value)
|
254
|
+
layer.kml.setOptions({suppressInfoWindows:!layer.kml.get('suppressInfoWindows')})
|
255
|
+
layer.kml.setOptions({suppressInfoWindows:!layer.kml.get('suppressInfoWindows')})
|
256
|
+
}
|
239
257
|
|
240
258
|
// INIT
|
241
259
|
|
@@ -245,5 +263,5 @@ window.MapLayerManager = function(map){
|
|
245
263
|
|
246
264
|
// PUBLIC INTERFACE
|
247
265
|
|
248
|
-
return {cacheAndLoadKMLLayer:cacheAndLoadKMLLayer, loadKMLLayer:loadKMLLayer, centerWhenLoaded:centerWhenLoaded, addLayer:addLayer, removeLayer:removeLayer, layerNames:layerNames, map:map, loadingCount:loadingCount}
|
266
|
+
return {cacheAndLoadKMLLayer:cacheAndLoadKMLLayer, loadKMLLayer:loadKMLLayer, centerWhenLoaded:centerWhenLoaded, addLayer:addLayer, removeLayer:removeLayer, layerNames:layerNames, map:map, loadingCount:loadingCount, closeInfowindows:closeInfowindows, closeInfowindowsExcept:closeInfowindowsExcept}
|
249
267
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kmz_compressor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Wallace
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|