September 13, 2011
maperipy: Maperitive API for Python - A First Glimpse

A few days ago I started implementing maperipy, a Maperitive API for Python. It turns out to be a quite uncomplicated thing to do, compared to all infrastructure stuff I’m working on for the next Maperitive release, so it’s a kind of a relaxation between all the hard work.

The API is still very young and unsophisticated, but I’m very excited about it, because it could provide a whole new dimension of functionality to Maperitive users.

Here’s a simple Python script that clears the map and then adds a custom Web map to it (with custom copyright text):

from maperipy import MapLayer

map.clear_map();
layer = map.add_web_map_custom(
        "my hiking map", 
        ["http://beta1234.com.sunflower.arvixe.com/maps/tiles"])
layer.copyright = "it's made by me"
layer.opacity = 0.75

Another one, which scrolls the map along the X-axis:

from maperipy import MapPosition
import time

pos = map.position;

for n in range(10):
    map.position = MapPosition(15 + n/10.0, pos.y, 11)
    app.refresh_map()
    time.sleep(0.3)

First versions of maperipy will probably be available after I finish the work on the next major release of Maperitive. Hopefully some time in October.

  1. corrie-stewart reblogged this from braincrunch
  2. braincrunch posted this