kmz_compressor 2.0.11 → 2.0.17

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16c6b78aacfa9bbcd64d2e072eb95ff06cb4c8c1
4
- data.tar.gz: a8253da6b5ddb318f5fee79190b0b3c567b69f24
3
+ metadata.gz: 4a016ad49b9311b3f886bef8fc9ddbaf789fdafb
4
+ data.tar.gz: b42020c3acdd4a0a483737f4d54f0d2ee656b9fc
5
5
  SHA512:
6
- metadata.gz: c8d220ee9dfca45aeab7553af0251fddeff7fbb3edd4806775c6cc951f5910b453984b162f8a58c01bfb41a75f8ad9beb707b797f29f8a5b471068c095b93a14
7
- data.tar.gz: a2a5f481527b178bbba9e13982ba08e76cf1be49a44ecf8ea14dff5144f03ba411bacc0c0e5a24f222106bb21cadd1819882fdb0f60151721dcb31790fc13dd5
6
+ metadata.gz: 2feb0c49d00e5dd6e9a240ed63e46dfdca0e9ff48eecc5cb47df58bf7141154e34893eed1149546c09f616da108ce8d0fc80632704d83465baadbe5204084479
7
+ data.tar.gz: f479543d56fdfe774562ed292e4ecc0f7614f50c29238c0b8b15f0c9beb2c74a644e27a8f49d0c8d69b117da9a5a842e1d329e99bc852f880b352f42dd5069a0
@@ -1,2 +1,3 @@
1
+ //= require kmz_compressor/polyfills
1
2
  //= require kmz_compressor/sha2
2
- //= require kmz_compressor/map_layer_manager
3
+ //= require kmz_compressor/map_layer_manager
@@ -49,11 +49,12 @@ window.MapLayerManager = function(map){
49
49
 
50
50
  // Generates the url of the cached KMZ for the given kmlURL
51
51
  function cachedKMZURL(kmlURL){
52
- var url = $('<a href="' + kmlURL + '"/>')[0]
53
- return url.protocol + '//' + url.host + '/kmz/' + hex_sha256(kmlURL) + '.kmz'
52
+ var url = urlToObject(kmlURL)
53
+ url.href = '/kmz/' + hex_sha256(kmlURL) + '.kmz'
54
+ return url.href
54
55
  }
55
56
 
56
- function centerWhenLoaded(layerNamez){
57
+ function centerWhenLoaded(layerNamez, options){
57
58
  layerNamez = makeArray(layerNamez)
58
59
 
59
60
  var handler = function(){
@@ -64,7 +65,7 @@ window.MapLayerManager = function(map){
64
65
 
65
66
  if (areLayersLoaded(layerNamez)){
66
67
  $(map.getDiv()).unbind(layerLoadedEventName, handler)
67
- centerOnLayers(layerNamez);
68
+ centerOnLayers(layerNamez, options);
68
69
  }
69
70
  }
70
71
 
@@ -138,7 +139,7 @@ window.MapLayerManager = function(map){
138
139
  return true
139
140
  }
140
141
 
141
- function centerOnLayers(layerNames){
142
+ function centerOnLayers(layerNames, options){
142
143
  var bounds;
143
144
  layerNames = makeArray(layerNames)
144
145
  sweep() // Discard old layers before we generate the bounds
@@ -154,8 +155,14 @@ window.MapLayerManager = function(map){
154
155
  bounds.union(layer.kml.getDefaultViewport());
155
156
  }
156
157
  }
158
+ var checkZoom = options.maxZoom && map.getZoom() <= options.maxZoom
159
+
157
160
  if (bounds){
158
- map.fitBounds(bounds);
161
+ map.fitBounds(bounds)
162
+ }
163
+
164
+ if (checkZoom && map.getZoom() > options.maxZoom){
165
+ map.setZoom(options.maxZoom)
159
166
  }
160
167
  }
161
168
 
@@ -217,8 +224,8 @@ window.MapLayerManager = function(map){
217
224
  // Replace spaces with pluses so we don't have problems with some things turning them into %20s and some not
218
225
  // Matches the middleware process
219
226
  function sanitizeURI(uri){
220
- var url = $('<a href="' + uri + '"/>')[0]
221
- 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
227
+ var url = urlToObject(uri)
228
+ var pathname = ('/' + decodeURI(url.pathname)).replace(/^\/+/, '/').trim() // Ensure there is a leading slash (IE doesn't provide one, Chrome does, FF does)
222
229
  var search = decodeURIComponent(url.search.replace(/\+/g, '%20')).trim().replace(/^\?/, '') // Ensure all "plus spaces" are hex encoded spaces
223
230
 
224
231
  output = pathname
@@ -236,8 +243,9 @@ window.MapLayerManager = function(map){
236
243
  return encodeURIComponent(kv).replace(/'/g, '%27')
237
244
  }).join('=')
238
245
  }).join('&')
246
+ url.href = output
239
247
 
240
- return url.protocol + '//' + url.host + output
248
+ return url.href
241
249
  }
242
250
 
243
251
  function closeInfowindowsExcept(layerName){
@@ -268,6 +276,10 @@ window.MapLayerManager = function(map){
268
276
  }
269
277
  }
270
278
 
279
+ function urlToObject(url){
280
+ return $('<a>').attr('href', url)[0]
281
+ }
282
+
271
283
  // INIT
272
284
 
273
285
  // Because google events sometimes get missed, we ensure we're up to date every now and again
@@ -0,0 +1,7 @@
1
+
2
+ // IE8 Doesn't support String.trim()
3
+ if (!String.prototype.trim) {
4
+ String.prototype.trim = function () {
5
+ return this.replace(/^\s+|\s+$/g, '');
6
+ };
7
+ }
@@ -1,3 +1,3 @@
1
1
  module KMZCompressor
2
- VERSION = "2.0.11"
2
+ VERSION = "2.0.17"
3
3
  end
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.11
4
+ version: 2.0.17
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-08-14 00:00:00.000000000 Z
12
+ date: 2014-08-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -57,6 +57,7 @@ files:
57
57
  - README.rdoc
58
58
  - app/assets/javascripts/kmz_compressor.js
59
59
  - app/assets/javascripts/kmz_compressor/map_layer_manager.js
60
+ - app/assets/javascripts/kmz_compressor/polyfills.js
60
61
  - app/assets/javascripts/kmz_compressor/sha2.js
61
62
  - lib/kmz_compressor.rb
62
63
  - lib/kmz_compressor/engine.rb
@@ -82,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
83
  version: '0'
83
84
  requirements: []
84
85
  rubyforge_project:
85
- rubygems_version: 2.2.2
86
+ rubygems_version: 2.4.1
86
87
  signing_key:
87
88
  specification_version: 4
88
89
  summary: Rack Middleware which retrieves KML from Rails and produces KMZ for the client.