Skip to content

Commit 22c5f95

Browse files
committed
First public release
0 parents  commit 22c5f95

File tree

7 files changed

+372
-0
lines changed

7 files changed

+372
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.build
2+
.build*

HISTORY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 2.1.4
2+
3+
* First public version.

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# pauloborges:mapbox
2+
3+
Mapbox.js for [Meteor](https://www.meteor.com/) apps. Current Mapbox version: `2.1.4`.
4+
5+
## Install
6+
7+
$ cd to/my/meteor/project
8+
$ meteor add pauloborges:mapbox@2.1.4
9+
10+
or (if you want to modify the code):
11+
12+
$ cd to/my/meteor/project
13+
$ mkdir packages # ensure that packages folder exists
14+
$ git clone https://github.com/pauloborges/meteor-mapbox.git packages/mapbox
15+
$ meteor add mapbox
16+
17+
## Supported plugins
18+
19+
All plugins listed [here](https://www.mapbox.com/mapbox.js/plugins/) are
20+
supported:
21+
22+
* [directions](https://www.mapbox.com/mapbox.js/plugins/#mapbox-directions)
23+
* [zoomslider](https://www.mapbox.com/mapbox.js/plugins/#leaflet-zoomslider)
24+
* [pip](https://www.mapbox.com/mapbox.js/plugins/#point-in-polygon)
25+
* [osm](https://www.mapbox.com/mapbox.js/plugins/#leaflet-osm)
26+
* [omnivore](https://www.mapbox.com/mapbox.js/plugins/#leaflet-omnivore)
27+
* [minimap](https://www.mapbox.com/mapbox.js/plugins/#leaflet-minimap)
28+
* [markercluster](https://www.mapbox.com/mapbox.js/plugins/#leaflet-markercluster)
29+
* [locate](https://www.mapbox.com/mapbox.js/plugins/#leaflet-locatecontrol)
30+
* [label](https://www.mapbox.com/mapbox.js/plugins/#leaflet-label)
31+
* [image](https://www.mapbox.com/mapbox.js/plugins/#leaflet-image)
32+
* [heat](https://www.mapbox.com/mapbox.js/plugins/#leaflet-heat)
33+
* [hash](https://www.mapbox.com/mapbox.js/plugins/#leaflet-hash)
34+
* [geodesy](https://www.mapbox.com/mapbox.js/plugins/#leaflet-geodesy)
35+
* [fullscreen](https://www.mapbox.com/mapbox.js/plugins/#leaflet-fullscreen)
36+
* [draw](https://www.mapbox.com/mapbox.js/plugins/#leaflet-draw)
37+
* [geojsonExtend](https://www.mapbox.com/mapbox.js/plugins/#static-map-from-geojson-with-geo-viewport)
38+
* [geoViewport](https://www.mapbox.com/mapbox.js/plugins/#static-map-from-bounds-with-geo-viewport)
39+
* [arc](https://www.mapbox.com/mapbox.js/plugins/#arcjs)
40+
41+
## Usage
42+
43+
Call `Mapbox.load(pluginList)` in your client code. Use `Mapbox.loaded()` to
44+
check if it finished loading. This function is reactive.
45+
46+
### Example
47+
48+
Mapbox.load('minimap', 'markercluster');
49+
50+
Deps.autorun(function () {
51+
if (Mapbox.loaded()) {
52+
L.mapbox.accessToken = MY_ACCESS_TOKEN;
53+
var map = L.mapbox.map('map', MY_MAP_ID);
54+
}
55+
});

mapbox.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* Copyright (c) 2014 Paulo Sérgio Borges de Oliveira Filho
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a
4+
* copy of this software and associated documentation files (the "Software"),
5+
* to deal in the Software without restriction, including without limitation
6+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
7+
* and/or sell copies of the Software, and to permit persons to whom the
8+
* Software is furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19+
* DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
body {
23+
margin: 0;
24+
padding: 0;
25+
}
26+
27+
#map.mapbox {
28+
position: absolute;
29+
top: 0;
30+
bottom: 0;
31+
width: 100%;
32+
}

mapbox.js

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
/* Copyright (c) 2014 Paulo Sérgio Borges de Oliveira Filho
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a
4+
* copy of this software and associated documentation files (the "Software"),
5+
* to deal in the Software without restriction, including without limitation
6+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
7+
* and/or sell copies of the Software, and to permit persons to whom the
8+
* Software is furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19+
* DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
var FILES = {
23+
mapbox: {
24+
js: ['https://api.tiles.mapbox.com/mapbox.js/v2.1.4/mapbox.js'],
25+
css: ['https://api.tiles.mapbox.com/mapbox.js/v2.1.4/mapbox.css'],
26+
},
27+
28+
directions: {
29+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.0.1/mapbox.directions.js'],
30+
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.0.1/mapbox.directions.css']
31+
},
32+
33+
zoomslider: {
34+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-zoomslider/v0.7.0/L.Control.Zoomslider.js'],
35+
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-zoomslider/v0.7.0/L.Control.Zoomslider.css']
36+
},
37+
38+
pip: {
39+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-pip/v0.0.2/leaflet-pip.js'],
40+
css: []
41+
},
42+
43+
osm: {
44+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-osm/v0.1.0/leaflet-osm.js'],
45+
css: []
46+
},
47+
48+
omnivore: {
49+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-omnivore/v0.2.0/leaflet-omnivore.min.js'],
50+
css: []
51+
},
52+
53+
minimap: {
54+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-minimap/v1.0.0/Control.MiniMap.js'],
55+
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-minimap/v1.0.0/Control.MiniMap.css']
56+
},
57+
58+
markercluster: {
59+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v0.4.0/leaflet.markercluster.js'],
60+
css: [
61+
'https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v0.4.0/MarkerCluster.css',
62+
'https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v0.4.0/MarkerCluster.Default.css'
63+
],
64+
},
65+
66+
// FIXME: Doesn't support IE<9
67+
// https://www.mapbox.com/mapbox.js/example/v1.0.0/leaflet-locatecontrol/
68+
locate: {
69+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-locatecontrol/v0.24.0/L.Control.Locate.js'],
70+
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-locatecontrol/v0.24.0/L.Control.Locate.css']
71+
},
72+
73+
label: {
74+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-label/v0.2.1/leaflet.label.js'],
75+
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-label/v0.2.1/leaflet.label.css']
76+
},
77+
78+
image: {
79+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-image/v0.0.4/leaflet-image.js'],
80+
css: []
81+
},
82+
83+
heat: {
84+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-heat/v0.1.0/leaflet-heat.js'],
85+
css: []
86+
},
87+
88+
hash: {
89+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-hash/v0.2.1/leaflet-hash.js'],
90+
css: []
91+
},
92+
93+
geodesy: {
94+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-geodesy/v0.1.0/leaflet-geodesy.js'],
95+
css: []
96+
},
97+
98+
fullscreen: {
99+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v0.0.3/Leaflet.fullscreen.min.js'],
100+
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v0.0.3/leaflet.fullscreen.css']
101+
},
102+
103+
draw: {
104+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-draw/v0.2.2/leaflet.draw.js'],
105+
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-draw/v0.2.2/leaflet.draw.css']
106+
},
107+
108+
geojsonExtend: {
109+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/geojson-extent/v0.0.1/geojson-extent.js'],
110+
css: []
111+
},
112+
113+
geoViewport: {
114+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/geo-viewport/v0.1.1/geo-viewport.js'],
115+
css: []
116+
},
117+
118+
arc: {
119+
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/arc.js/v0.1.0/arc.js'],
120+
css: []
121+
}
122+
};
123+
124+
var deps = new Deps.Dependency;
125+
var loaded = false;
126+
127+
var loadCount = 0;
128+
var loadCallback = null;
129+
130+
var pluginCount = 0;
131+
var plugins = null;
132+
133+
var onLoaded = function () {
134+
loaded = true;
135+
deps.changed();
136+
};
137+
138+
var onPluginLoaded = function () {
139+
pluginCount--;
140+
141+
if (pluginCount == 0)
142+
onLoaded();
143+
};
144+
145+
var onMapboxLoaded = function () {
146+
pluginCount = _.size(plugins);
147+
148+
if (pluginCount == 0) {
149+
onLoaded();
150+
return;
151+
}
152+
153+
_.each(plugins, function (pluginName) {
154+
var plugin = FILES[pluginName];
155+
156+
if (plugin)
157+
loadFiles(plugin, onPluginLoaded);
158+
else
159+
console.log('Invalid MapBox plugin: "' + pluginName + '"');
160+
});
161+
};
162+
163+
var onLoadedFile = function (url) {
164+
if (Mapbox.debug)
165+
console.log('Loaded "' + url + '"');
166+
167+
loadCount--;
168+
169+
if (loadCount == 0)
170+
loadCallback();
171+
};
172+
173+
var loadScript = function (src) {
174+
var elem = document.createElement('script');
175+
elem.type = 'text/javascript';
176+
elem.src = src;
177+
elem.defer = true;
178+
179+
elem.addEventListener('load', _.partial(onLoadedFile, src), false);
180+
181+
var head = document.getElementsByTagName('head')[0];
182+
head.appendChild(elem);
183+
};
184+
185+
var loadCss = function (href) {
186+
var elem = document.createElement('link');
187+
elem.rel = 'stylesheet';
188+
elem.href = href;
189+
190+
elem.addEventListener('load', _.partial(onLoadedFile, href), false);
191+
192+
var head = document.getElementsByTagName('head')[0];
193+
head.appendChild(elem);
194+
};
195+
196+
var loadFiles = function (files, cb) {
197+
loadCount = _.size(files.js) + _.size(files.css);
198+
loadCallback = cb;
199+
200+
_.each(files.js, function (url) {
201+
loadScript(url);
202+
});
203+
204+
_.each(files.css, function (url) {
205+
loadCss(url);
206+
});
207+
};
208+
209+
Mapbox = {
210+
debug: false,
211+
212+
load: function () {
213+
plugins = _.values(arguments);
214+
loadFiles(FILES.mapbox, onMapboxLoaded);
215+
},
216+
217+
loaded: function () {
218+
deps.depend();
219+
return loaded;
220+
}
221+
};

package.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* Copyright (c) 2014 Paulo Sérgio Borges de Oliveira Filho
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a
4+
* copy of this software and associated documentation files (the "Software"),
5+
* to deal in the Software without restriction, including without limitation
6+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
7+
* and/or sell copies of the Software, and to permit persons to whom the
8+
* Software is furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19+
* DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
Package.describe({
23+
name: 'pauloborges:mapbox',
24+
summary: 'Mapbox.js for Meteor apps',
25+
version: '2.1.4',
26+
git: 'https://github.com/pauloborges/meteor-mapbox.git'
27+
});
28+
29+
Package.onUse(function (api) {
30+
api.versionsFrom('METEOR@1.0');
31+
api.use(['deps', 'underscore'], ['client']);
32+
33+
api.addFiles(['mapbox.js', 'mapbox.css'], ['client']);
34+
35+
api.export('Mapbox', ['client']);
36+
});

versions.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"dependencies": [
3+
[
4+
"deps",
5+
"1.0.5"
6+
],
7+
[
8+
"meteor",
9+
"1.1.3"
10+
],
11+
[
12+
"tracker",
13+
"1.0.3"
14+
],
15+
[
16+
"underscore",
17+
"1.0.1"
18+
]
19+
],
20+
"pluginDependencies": [],
21+
"toolVersion": "meteor-tool@1.0.35",
22+
"format": "1.0"
23+
}

0 commit comments

Comments
 (0)