-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 22c5f95
Showing
7 changed files
with
372 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.build | ||
.build* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 2.1.4 | ||
|
||
* First public version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# pauloborges:mapbox | ||
|
||
Mapbox.js for [Meteor](https://www.meteor.com/) apps. Current Mapbox version: `2.1.4`. | ||
|
||
## Install | ||
|
||
$ cd to/my/meteor/project | ||
$ meteor add pauloborges:[email protected] | ||
|
||
or (if you want to modify the code): | ||
|
||
$ cd to/my/meteor/project | ||
$ mkdir packages # ensure that packages folder exists | ||
$ git clone https://github.com/pauloborges/meteor-mapbox.git packages/mapbox | ||
$ meteor add mapbox | ||
|
||
## Supported plugins | ||
|
||
All plugins listed [here](https://www.mapbox.com/mapbox.js/plugins/) are | ||
supported: | ||
|
||
* [directions](https://www.mapbox.com/mapbox.js/plugins/#mapbox-directions) | ||
* [zoomslider](https://www.mapbox.com/mapbox.js/plugins/#leaflet-zoomslider) | ||
* [pip](https://www.mapbox.com/mapbox.js/plugins/#point-in-polygon) | ||
* [osm](https://www.mapbox.com/mapbox.js/plugins/#leaflet-osm) | ||
* [omnivore](https://www.mapbox.com/mapbox.js/plugins/#leaflet-omnivore) | ||
* [minimap](https://www.mapbox.com/mapbox.js/plugins/#leaflet-minimap) | ||
* [markercluster](https://www.mapbox.com/mapbox.js/plugins/#leaflet-markercluster) | ||
* [locate](https://www.mapbox.com/mapbox.js/plugins/#leaflet-locatecontrol) | ||
* [label](https://www.mapbox.com/mapbox.js/plugins/#leaflet-label) | ||
* [image](https://www.mapbox.com/mapbox.js/plugins/#leaflet-image) | ||
* [heat](https://www.mapbox.com/mapbox.js/plugins/#leaflet-heat) | ||
* [hash](https://www.mapbox.com/mapbox.js/plugins/#leaflet-hash) | ||
* [geodesy](https://www.mapbox.com/mapbox.js/plugins/#leaflet-geodesy) | ||
* [fullscreen](https://www.mapbox.com/mapbox.js/plugins/#leaflet-fullscreen) | ||
* [draw](https://www.mapbox.com/mapbox.js/plugins/#leaflet-draw) | ||
* [geojsonExtend](https://www.mapbox.com/mapbox.js/plugins/#static-map-from-geojson-with-geo-viewport) | ||
* [geoViewport](https://www.mapbox.com/mapbox.js/plugins/#static-map-from-bounds-with-geo-viewport) | ||
* [arc](https://www.mapbox.com/mapbox.js/plugins/#arcjs) | ||
|
||
## Usage | ||
|
||
Call `Mapbox.load(pluginList)` in your client code. Use `Mapbox.loaded()` to | ||
check if it finished loading. This function is reactive. | ||
|
||
### Example | ||
|
||
Mapbox.load('minimap', 'markercluster'); | ||
|
||
Deps.autorun(function () { | ||
if (Mapbox.loaded()) { | ||
L.mapbox.accessToken = MY_ACCESS_TOKEN; | ||
var map = L.mapbox.map('map', MY_MAP_ID); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* Copyright (c) 2014 Paulo Sérgio Borges de Oliveira Filho | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#map.mapbox { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
/* Copyright (c) 2014 Paulo Sérgio Borges de Oliveira Filho | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
var FILES = { | ||
mapbox: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/v2.1.4/mapbox.js'], | ||
css: ['https://api.tiles.mapbox.com/mapbox.js/v2.1.4/mapbox.css'], | ||
}, | ||
|
||
directions: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.0.1/mapbox.directions.js'], | ||
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.0.1/mapbox.directions.css'] | ||
}, | ||
|
||
zoomslider: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-zoomslider/v0.7.0/L.Control.Zoomslider.js'], | ||
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-zoomslider/v0.7.0/L.Control.Zoomslider.css'] | ||
}, | ||
|
||
pip: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-pip/v0.0.2/leaflet-pip.js'], | ||
css: [] | ||
}, | ||
|
||
osm: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-osm/v0.1.0/leaflet-osm.js'], | ||
css: [] | ||
}, | ||
|
||
omnivore: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-omnivore/v0.2.0/leaflet-omnivore.min.js'], | ||
css: [] | ||
}, | ||
|
||
minimap: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-minimap/v1.0.0/Control.MiniMap.js'], | ||
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-minimap/v1.0.0/Control.MiniMap.css'] | ||
}, | ||
|
||
markercluster: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v0.4.0/leaflet.markercluster.js'], | ||
css: [ | ||
'https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v0.4.0/MarkerCluster.css', | ||
'https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v0.4.0/MarkerCluster.Default.css' | ||
], | ||
}, | ||
|
||
// FIXME: Doesn't support IE<9 | ||
// https://www.mapbox.com/mapbox.js/example/v1.0.0/leaflet-locatecontrol/ | ||
locate: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-locatecontrol/v0.24.0/L.Control.Locate.js'], | ||
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-locatecontrol/v0.24.0/L.Control.Locate.css'] | ||
}, | ||
|
||
label: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-label/v0.2.1/leaflet.label.js'], | ||
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-label/v0.2.1/leaflet.label.css'] | ||
}, | ||
|
||
image: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-image/v0.0.4/leaflet-image.js'], | ||
css: [] | ||
}, | ||
|
||
heat: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-heat/v0.1.0/leaflet-heat.js'], | ||
css: [] | ||
}, | ||
|
||
hash: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-hash/v0.2.1/leaflet-hash.js'], | ||
css: [] | ||
}, | ||
|
||
geodesy: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-geodesy/v0.1.0/leaflet-geodesy.js'], | ||
css: [] | ||
}, | ||
|
||
fullscreen: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v0.0.3/Leaflet.fullscreen.min.js'], | ||
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v0.0.3/leaflet.fullscreen.css'] | ||
}, | ||
|
||
draw: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-draw/v0.2.2/leaflet.draw.js'], | ||
css: ['https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-draw/v0.2.2/leaflet.draw.css'] | ||
}, | ||
|
||
geojsonExtend: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/geojson-extent/v0.0.1/geojson-extent.js'], | ||
css: [] | ||
}, | ||
|
||
geoViewport: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/geo-viewport/v0.1.1/geo-viewport.js'], | ||
css: [] | ||
}, | ||
|
||
arc: { | ||
js: ['https://api.tiles.mapbox.com/mapbox.js/plugins/arc.js/v0.1.0/arc.js'], | ||
css: [] | ||
} | ||
}; | ||
|
||
var deps = new Deps.Dependency; | ||
var loaded = false; | ||
|
||
var loadCount = 0; | ||
var loadCallback = null; | ||
|
||
var pluginCount = 0; | ||
var plugins = null; | ||
|
||
var onLoaded = function () { | ||
loaded = true; | ||
deps.changed(); | ||
}; | ||
|
||
var onPluginLoaded = function () { | ||
pluginCount--; | ||
|
||
if (pluginCount == 0) | ||
onLoaded(); | ||
}; | ||
|
||
var onMapboxLoaded = function () { | ||
pluginCount = _.size(plugins); | ||
|
||
if (pluginCount == 0) { | ||
onLoaded(); | ||
return; | ||
} | ||
|
||
_.each(plugins, function (pluginName) { | ||
var plugin = FILES[pluginName]; | ||
|
||
if (plugin) | ||
loadFiles(plugin, onPluginLoaded); | ||
else | ||
console.log('Invalid MapBox plugin: "' + pluginName + '"'); | ||
}); | ||
}; | ||
|
||
var onLoadedFile = function (url) { | ||
if (Mapbox.debug) | ||
console.log('Loaded "' + url + '"'); | ||
|
||
loadCount--; | ||
|
||
if (loadCount == 0) | ||
loadCallback(); | ||
}; | ||
|
||
var loadScript = function (src) { | ||
var elem = document.createElement('script'); | ||
elem.type = 'text/javascript'; | ||
elem.src = src; | ||
elem.defer = true; | ||
|
||
elem.addEventListener('load', _.partial(onLoadedFile, src), false); | ||
|
||
var head = document.getElementsByTagName('head')[0]; | ||
head.appendChild(elem); | ||
}; | ||
|
||
var loadCss = function (href) { | ||
var elem = document.createElement('link'); | ||
elem.rel = 'stylesheet'; | ||
elem.href = href; | ||
|
||
elem.addEventListener('load', _.partial(onLoadedFile, href), false); | ||
|
||
var head = document.getElementsByTagName('head')[0]; | ||
head.appendChild(elem); | ||
}; | ||
|
||
var loadFiles = function (files, cb) { | ||
loadCount = _.size(files.js) + _.size(files.css); | ||
loadCallback = cb; | ||
|
||
_.each(files.js, function (url) { | ||
loadScript(url); | ||
}); | ||
|
||
_.each(files.css, function (url) { | ||
loadCss(url); | ||
}); | ||
}; | ||
|
||
Mapbox = { | ||
debug: false, | ||
|
||
load: function () { | ||
plugins = _.values(arguments); | ||
loadFiles(FILES.mapbox, onMapboxLoaded); | ||
}, | ||
|
||
loaded: function () { | ||
deps.depend(); | ||
return loaded; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* Copyright (c) 2014 Paulo Sérgio Borges de Oliveira Filho | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
Package.describe({ | ||
name: 'pauloborges:mapbox', | ||
summary: 'Mapbox.js for Meteor apps', | ||
version: '2.1.4', | ||
git: 'https://github.com/pauloborges/meteor-mapbox.git' | ||
}); | ||
|
||
Package.onUse(function (api) { | ||
api.versionsFrom('[email protected]'); | ||
api.use(['deps', 'underscore'], ['client']); | ||
|
||
api.addFiles(['mapbox.js', 'mapbox.css'], ['client']); | ||
|
||
api.export('Mapbox', ['client']); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"dependencies": [ | ||
[ | ||
"deps", | ||
"1.0.5" | ||
], | ||
[ | ||
"meteor", | ||
"1.1.3" | ||
], | ||
[ | ||
"tracker", | ||
"1.0.3" | ||
], | ||
[ | ||
"underscore", | ||
"1.0.1" | ||
] | ||
], | ||
"pluginDependencies": [], | ||
"toolVersion": "[email protected]", | ||
"format": "1.0" | ||
} |