leaflet-active-area-rails 0.0.1
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 +7 -0
- data/Gemfile +4 -0
- data/LICENSE +4 -0
- data/README.md +23 -0
- data/Rakefile +2 -0
- data/leaflet-active-area-rails.gemspec +18 -0
- data/lib/leaflet-active-area-rails.rb +13 -0
- data/lib/leaflet-active-area-rails/version.rb +7 -0
- data/vendor/assets/javascripts/leaflet.activearea.js +152 -0
- metadata +51 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 83e2f683a940ab39f6d4adb335f23c0febf52fef
|
|
4
|
+
data.tar.gz: a7e2cf6f9a8e204b38c898a11ab06ea33a1ad253
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: da3f7fab3cd4ea34346b6e55ba0b6101a2a3070bbec86477dff8d08ec6bcbcb29e2aa3b75c6fec9b3fe19f3b6d6b442a3541a3f4706f3f63f16f4f4b1d206e57
|
|
7
|
+
data.tar.gz: a905c6a49a8f350de9641c9d37661e7a10ea765ae0d823421725602971a8050e94727a1cf0a83e4ef0e386ebd5775e743389983cf7daee4c559feea72e24c8fb
|
data/Gemfile
ADDED
data/LICENSE
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# leaflet-active-area-rails
|
|
2
|
+
|
|
3
|
+
[Leaflet-active-area](https://github.com/Mappy/Leaflet-active-area) packaged for the rails asset pipeline
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add `leaflet-active-area` to your Gemfile and run `bundle install`:
|
|
8
|
+
|
|
9
|
+
gem 'leaflet-active-area'
|
|
10
|
+
|
|
11
|
+
Include javascript assets in `app/assets/javascripts/application.js`
|
|
12
|
+
|
|
13
|
+
//= require leaflet-active-area
|
|
14
|
+
|
|
15
|
+
Look at Leaflet-active-area for further usage details.
|
|
16
|
+
|
|
17
|
+
## Contributing
|
|
18
|
+
|
|
19
|
+
Fork & send a pull with decent commit messages
|
|
20
|
+
|
|
21
|
+
## Credits
|
|
22
|
+
|
|
23
|
+
[Samuel Piquet, Mappy](https://github.com/sa3m)
|
data/Rakefile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path('../lib/leaflet-active-area-rails/version', __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.authors = ["Samuel Piquet"]
|
|
6
|
+
# gem.email = [""]
|
|
7
|
+
|
|
8
|
+
gem.homepage = "https://github.com/Mappy/Leaflet-active-area"
|
|
9
|
+
gem.name = "leaflet-active-area-rails"
|
|
10
|
+
gem.description = %q{Leaflet-active-area plugin packaged for the rails 3 asset pipeline}
|
|
11
|
+
gem.summary = %q{Leaflet-active-area plugin for rails 3}
|
|
12
|
+
gem.license = "Apache-2.0"
|
|
13
|
+
|
|
14
|
+
gem.files = `git ls-files`.split($\)
|
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
16
|
+
gem.require_paths = ["lib"]
|
|
17
|
+
gem.version = Leaflet::ActiveArea::Rails::VERSION
|
|
18
|
+
end
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
(function(previousMethods){
|
|
2
|
+
if (typeof previousMethods === 'undefined') {
|
|
3
|
+
// Defining previously that object allows you to use that plugin even if you have overridden L.map
|
|
4
|
+
previousMethods = {
|
|
5
|
+
getCenter: L.Map.prototype.getCenter,
|
|
6
|
+
setView: L.Map.prototype.setView,
|
|
7
|
+
setZoomAround: L.Map.prototype.setZoomAround,
|
|
8
|
+
getBoundsZoom: L.Map.prototype.getBoundsZoom
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
L.Map.include({
|
|
14
|
+
getBounds: function() {
|
|
15
|
+
if (this._viewport) {
|
|
16
|
+
return this.getViewportLatLngBounds()
|
|
17
|
+
} else {
|
|
18
|
+
var bounds = this.getPixelBounds(),
|
|
19
|
+
sw = this.unproject(bounds.getBottomLeft()),
|
|
20
|
+
ne = this.unproject(bounds.getTopRight());
|
|
21
|
+
|
|
22
|
+
return new L.LatLngBounds(sw, ne);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
getViewport: function() {
|
|
27
|
+
return this._viewport;
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
getViewportBounds: function() {
|
|
31
|
+
var vp = this._viewport,
|
|
32
|
+
topleft = L.point(vp.offsetLeft, vp.offsetTop),
|
|
33
|
+
vpsize = L.point(vp.clientWidth, vp.clientHeight);
|
|
34
|
+
|
|
35
|
+
if (vpsize.x === 0 || vpsize.y === 0) {
|
|
36
|
+
//Our own viewport has no good size - so we fallback to the container size:
|
|
37
|
+
vp = this.getContainer();
|
|
38
|
+
if(vp){
|
|
39
|
+
topleft = L.point(0, 0);
|
|
40
|
+
vpsize = L.point(vp.clientWidth, vp.clientHeight);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return L.bounds(topleft, topleft.add(vpsize));
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
getViewportLatLngBounds: function() {
|
|
49
|
+
var bounds = this.getViewportBounds();
|
|
50
|
+
return L.latLngBounds(this.containerPointToLatLng(bounds.min), this.containerPointToLatLng(bounds.max));
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
getOffset: function() {
|
|
54
|
+
var mCenter = this.getSize().divideBy(2),
|
|
55
|
+
vCenter = this.getViewportBounds().getCenter();
|
|
56
|
+
|
|
57
|
+
return mCenter.subtract(vCenter);
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
getCenter: function () {
|
|
61
|
+
var center = previousMethods.getCenter.call(this);
|
|
62
|
+
|
|
63
|
+
if (this.getViewport()) {
|
|
64
|
+
var zoom = this.getZoom(),
|
|
65
|
+
point = this.project(center, zoom);
|
|
66
|
+
point = point.subtract(this.getOffset());
|
|
67
|
+
|
|
68
|
+
center = this.unproject(point, zoom);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return center;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
setView: function (center, zoom, options) {
|
|
75
|
+
center = L.latLng(center);
|
|
76
|
+
|
|
77
|
+
if (this.getViewport()) {
|
|
78
|
+
var point = this.project(center, zoom);
|
|
79
|
+
point = point.add(this.getOffset());
|
|
80
|
+
center = this.unproject(point, zoom);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return previousMethods.setView.call(this, center, zoom, options);
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
setZoomAround: function (latlng, zoom, options) {
|
|
87
|
+
var vp = this.getViewport();
|
|
88
|
+
|
|
89
|
+
if (vp) {
|
|
90
|
+
var scale = this.getZoomScale(zoom),
|
|
91
|
+
viewHalf = this.getViewportBounds().getCenter(),
|
|
92
|
+
containerPoint = latlng instanceof L.Point ? latlng : this.latLngToContainerPoint(latlng),
|
|
93
|
+
|
|
94
|
+
centerOffset = containerPoint.subtract(viewHalf).multiplyBy(1 - 1 / scale),
|
|
95
|
+
newCenter = this.containerPointToLatLng(viewHalf.add(centerOffset));
|
|
96
|
+
|
|
97
|
+
return this.setView(newCenter, zoom, {zoom: options});
|
|
98
|
+
} else {
|
|
99
|
+
return previousMethods.setZoomAround.call(this, latlng, zoom, options);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
getBoundsZoom: function (bounds, inside, padding) { // (LatLngBounds[, Boolean, Point]) -> Number
|
|
104
|
+
bounds = L.latLngBounds(bounds);
|
|
105
|
+
|
|
106
|
+
var zoom = this.getMinZoom() - (inside ? 1 : 0),
|
|
107
|
+
maxZoom = this.getMaxZoom(),
|
|
108
|
+
vp = this.getViewport(),
|
|
109
|
+
size = (vp) ? L.point(vp.clientWidth, vp.clientHeight) : this.getSize(),
|
|
110
|
+
|
|
111
|
+
nw = bounds.getNorthWest(),
|
|
112
|
+
se = bounds.getSouthEast(),
|
|
113
|
+
|
|
114
|
+
zoomNotFound = true,
|
|
115
|
+
boundsSize;
|
|
116
|
+
|
|
117
|
+
padding = L.point(padding || [0, 0]);
|
|
118
|
+
|
|
119
|
+
do {
|
|
120
|
+
zoom++;
|
|
121
|
+
boundsSize = this.project(se, zoom).subtract(this.project(nw, zoom)).add(padding);
|
|
122
|
+
zoomNotFound = !inside ? size.contains(boundsSize) : boundsSize.x < size.x || boundsSize.y < size.y;
|
|
123
|
+
|
|
124
|
+
} while (zoomNotFound && zoom <= maxZoom);
|
|
125
|
+
|
|
126
|
+
if (zoomNotFound && inside) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return inside ? zoom : zoom - 1;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
L.Map.include({
|
|
136
|
+
setActiveArea: function (css) {
|
|
137
|
+
if( !this._viewport ){
|
|
138
|
+
//Make viewport if not already made
|
|
139
|
+
var container = this.getContainer();
|
|
140
|
+
this._viewport = L.DomUtil.create('div', '');
|
|
141
|
+
container.insertBefore(this._viewport, container.firstChild);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (typeof css === 'string') {
|
|
145
|
+
this._viewport.className = css;
|
|
146
|
+
} else {
|
|
147
|
+
L.extend(this._viewport.style, css);
|
|
148
|
+
}
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
})(window.leafletActiveAreaPreviousMethods);
|
metadata
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: leaflet-active-area-rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Samuel Piquet
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Leaflet-active-area plugin packaged for the rails 3 asset pipeline
|
|
14
|
+
email:
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- Gemfile
|
|
20
|
+
- LICENSE
|
|
21
|
+
- README.md
|
|
22
|
+
- Rakefile
|
|
23
|
+
- leaflet-active-area-rails.gemspec
|
|
24
|
+
- lib/leaflet-active-area-rails.rb
|
|
25
|
+
- lib/leaflet-active-area-rails/version.rb
|
|
26
|
+
- vendor/assets/javascripts/leaflet.activearea.js
|
|
27
|
+
homepage: https://github.com/Mappy/Leaflet-active-area
|
|
28
|
+
licenses:
|
|
29
|
+
- Apache-2.0
|
|
30
|
+
metadata: {}
|
|
31
|
+
post_install_message:
|
|
32
|
+
rdoc_options: []
|
|
33
|
+
require_paths:
|
|
34
|
+
- lib
|
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: '0'
|
|
45
|
+
requirements: []
|
|
46
|
+
rubyforge_project:
|
|
47
|
+
rubygems_version: 2.4.5.1
|
|
48
|
+
signing_key:
|
|
49
|
+
specification_version: 4
|
|
50
|
+
summary: Leaflet-active-area plugin for rails 3
|
|
51
|
+
test_files: []
|