Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added function just for getting coords

  • Loading branch information...
commit 941f05b999c4144bc2d91c15f466bd92432e8e91 1 parent 1e98871
@coolaj86 coolaj86 authored
View
4 .gitignore
@@ -1,2 +1,6 @@
.DS_Store
*~
+node_modules
+*.sw*
+*.html
+pakmanaged*
View
3  example/index.jade
@@ -1,8 +1,7 @@
html
head
title Tolmey Test
- script(src='ender.min.js', type='text/javascript')
- script(src='gps.js', type='text/javascript')
+ script(src='pakmanaged.js', type='text/javascript')
body
h1 Tolmey Tester
p
View
2  example/gps.js → example/lib/app.js
@@ -7,7 +7,7 @@
function displayMapTileForCoordinates(event) {
event.preventDefault();
- var converter = new Tolmey()
+ var converter = Tolmey.create()
;
navigator.geolocation.getCurrentPosition(function (position) {
View
21 example/package.json
@@ -0,0 +1,21 @@
+{
+ "author": "AJ ONeal <coolaj86@gmail.com> (http://coolaj86.info/)",
+ "name": "tolmey-example",
+ "description": "A nice web app that uses tolmey for kicks",
+ "version": "0.1.0",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/SpotterRF/Tolmey.git"
+ },
+ "main": "lib/app.js",
+ "browserDependencies": {
+ "jeesh": "*"
+ , "tolmey": "0.5.x"
+ },
+ "dependencies": {},
+ "devDependencies": {},
+ "optionalDependencies": {},
+ "engines": {
+ "node": "*"
+ }
+}
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "tolmey",
"description": "easy mapping tile downloading",
- "version": "0.5.2",
+ "version": "0.5.3",
"homepage": "https://github.com/jergason/Tolmey",
"author": "Jamison Dance <jergason@gmail.com> (http://jamisondance.com)",
"main": "./tolmey.js",
View
41 tolmey.js
@@ -77,6 +77,30 @@
// The array is indexed by zoom level, so urls[15] is all the URLs for tiles that cover the area
// in zoom level 15, ect.
getTileURLs: function (opts) {
+ var coords = this.getTileCoords(opts)
+ , mappingSystem = "openstreetmap"
+ , urls = {}
+ ;
+
+ if (opts.hasOwnProperty("mappingSystem")) {
+ mappingSystem = opts.mappingSystem;
+ }
+
+ Object.keys(coords).forEach(function (zoom) {
+ var coord = coords[zoom]
+ ;
+
+ urls[zoom] = urls[zoom] || [];
+ urls[zoom].push({
+ url: this.getTileURL(mappingSystem, coord.x, coord.y, coord.zoom)
+ , coords: coord
+ });
+ });
+
+ return urls;
+ },
+
+ getTileCoords: function (opts) {
var north = this.translate(opts.lat, opts.lon, opts.radius, 0)
, south = this.translate(opts.lat, opts.lon, opts.radius, 180)
, west = this.translate(opts.lat, opts.lon, opts.radius, 270)
@@ -84,7 +108,6 @@
, urls = []
, origin
, i, j, z, y0, y1, x0, x1
- , mappingSystem = "openstreetmap"
, zoom = 12
, maxZoom = 20
;
@@ -95,27 +118,29 @@
if (opts.hasOwnProperty("maxZoom")) {
maxZoom = opts.maxZoom;
}
- if (opts.hasOwnProperty("mappingSystem")) {
- mappingSystem = opts.mappingSystem;
- }
for (i = 0; i <= maxZoom; i++) {
urls[i] = [];
}
- for (zoom; zoom <= maxZoom; zoom++) {
+ for (zoom; zoom <= maxZoom; zoom += 1) {
y0 = this.getMercatorFromGPS(north.latitude, north.longitude, zoom);
y1 = this.getMercatorFromGPS(south.latitude, south.longitude, zoom);
x0 = this.getMercatorFromGPS(west.latitude, west.longitude, zoom);
x1 = this.getMercatorFromGPS(east.latitude, east.longitude, zoom);
- for (i = x0.x; i <= x1.x; i++) {
- for (j = y0.y; j <= y1.y; j++) {
- urls[zoom].push({ url: this.getTileURL(mappingSystem, i, j, zoom), coords: { zoom: zoom, x: i, y: j }});
+ for (i = x0.x; i <= x1.x; i += 1) {
+ for (j = y0.y; j <= y1.y; j += 1) {
+ urls[zoom].push({
+ zoom: zoom
+ , x: i
+ , y: j
+ });
}
}
}
+
return urls;
},
Please sign in to comment.
Something went wrong with that request. Please try again.