Created
December 4, 2012 00:05
-
-
Save tmcw/4199233 to your computer and use it in GitHub Desktop.
ModestMaps-py Tiling with MapBox
This file contains hidden or 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
# Requires ModestMaps to be installed | |
# Don't do this unless you have a very good reason, and a MapBox account, | |
# and you replace the 'examples' tileset with a tileset in your account. | |
import ModestMaps as MM | |
from ModestMaps.Geo import MercatorProjection, deriveTransformation | |
from ModestMaps.Providers import IMapProvider | |
from math import pi | |
class MapBox(IMapProvider): | |
def __init__(self): | |
t = deriveTransformation(-pi, pi, 0, 0, pi, pi, 1, 0, -pi, -pi, 0, 1) | |
self.projection = MercatorProjection(0, t) | |
def tileWidth(self): | |
return 256 | |
def tileHeight(self): | |
return 256 | |
def getTileUrls(self, coordinate): | |
return ('http://api.tiles.mapbox.com/v3/examples.map-vyofok3q/%d/%d/%d.png' % (coordinate.zoom, coordinate.column, coordinate.row),) | |
m = MM.mapByCenterZoom(MapBox(), MM.Geo.Location(37.8, -78), 13, MM.Core.Point(1200, 600)) | |
m.draw().save('map.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think of MM as a js library. What do you mean by "Installed"? Are there py bindings?