Cartagen Wiki
Dynamic Loading

What’s Dynamic Loading?

Basically, if you look at cartagen.org, it loads map data in chunks, downloading new chunks every time you move the map. These come from our customized OpenStreetMap Planet Server and are found at the address: http://cartagen.org/api/0.6/geohash/xxxxx.json. This has the added benefit of only loading the data the user is looking at, not the whole map at once.

Think of it as loading a map in smaller pieces.

Regardless of how you set up the tiles (see later on this page for some options), you’ll need to configure Cartagen to look for them instead of a static data set.

If you’ve just downloaded Cartagen, you should have an index.html file that has the following inside:

Cartagen.setup({
			stylesheet: "static/rome/style.gss",
			static_map: true,
			static_map_layers: [
				"static/rome/park.js",
				"static/rome/rail.js",
				"static/rome/waterway.js",
				"static/rome/primary.js",
				"static/rome/secondary.js",
				"static/rome/building.js",
				"static/rome/area.js"
				],
			lat: 41.92,
			lng: 12.12
		})

Change static_map to ‘false’:

static_map: false,

Now Cartagen will look at /api/0.6/geohash/xxxxxx.json for map tiles. Now you need to be sure it will find something there… read on!

(Read more about how to customize Cartagen at Customizing Cartagen)

Keeping some tiles on your server

If you don’t want to run a Planet Server (if you’re not sure, then DONT!) you can ‘cheat’ by just copying some files from ours.

Cartagen looks locally at the web root of your project for these tiles, so for smaller projects, I’ve downloaded the tiles and kept them in a local /api/0.6/geohash/ directory; I’m happy to zip up all Manhattan tiles for you, so email me at [email protected] if you need them.

Proxying to our Planet Server

If you really do need to map the whole world, you STILL don’t need to run your own Planet Server; just BORROW OURS!

You can set up a proxy from your site to our planet server, so that any request to your site such as ‘yourserver.com/api/…’ would actually route to ‘cartagen.org/api/…’ - this would mean you’d get the latest updated version of the planet, since we try to regenerate our tiles every so often. Eventually we’ll have them running with up-to-the-minute data from OpenStreetMap

No, really! I need my own Planet Server!

You could potentially run your own Planet Server, but it’s a bit of a pain in the ass, and after all, if you only need a static dump of Manhattan, it doesn’t seem like it would be a problem to simply serve the static files.

There is more information at Planet Server, but this is unsupported. Contact [email protected] for more details, but don’t expect me to do it for you!