Introduction and examples: Difference between revisions
(Created) |
(Demo examples (that don't work in the Wiki) moved to webtools.csx) |
||
Line 61: | Line 61: | ||
</html> | </html> | ||
Produces [http:// | Produces [http://webtools.csx.cam.ac.uk/map-demo/test.html a page like this]. | ||
Here's a further example: [http://www.ucs.cam.ac.uk/about-us/where the normal UCS 'Where we are' page] reworked to [http:// | Here's a further example: [http://www.ucs.cam.ac.uk/about-us/where the normal UCS 'Where we are' page] reworked to [http://webtools.csx.cam.ac.uk/map-demo/where.html use the new map]. | ||
==Tile API== | ==Tile API== | ||
Line 71: | Line 71: | ||
''These examples use tiles from http://map.cam.ac.uk/ - because it currently requires Raven authentication they won't work properly until you've authenticated (once) to map.cam.ac.uk.'' | ''These examples use tiles from http://map.cam.ac.uk/ - because it currently requires Raven authentication they won't work properly until you've authenticated (once) to map.cam.ac.uk.'' | ||
Here are [http:// | Here are [http://webtools.csx.cam.ac.uk/map-demo/tiles.html some of the tiles that make up the city centre]. | ||
They follow the conventions of Open Street Map and other similar systems and so can be consumed in various ways. Here are some examples using third-party map APIs: | They follow the conventions of Open Street Map and other similar systems and so can be consumed in various ways. Here are some examples using third-party map APIs: | ||
* [http:// | * [http://webtools.csx.cam.ac.uk/map-demo/open-layers.html An example displaying our tiles, OSM's, or Google's] using [http://openlayers.org/ OpenLayers]. | ||
* [http:// | * [http://webtools.csx.cam.ac.uk/map-demo/leaflet.html An example with marker and shape overlay] using [http://leaflet.cloudmade.com/ Leaflet] | ||
* [http:// | * [http://webtools.csx.cam.ac.uk/map-demo/google.html A further example combining our tiles and Google's], this time using [https://developers.google.com/maps/ the Google Maps API] | ||
==Index API== | ==Index API== |
Revision as of 11:59, 27 June 2012
Basic use
- The map 'fronpage': http://map.cam.ac.uk/
API for linking to maps
The front page URL exposes a URL for linking to particular views based on searches - see The Map URL API for details. For example:
- http://map.cam.ac.uk/Computing+Service (location of the UCS)
- http://map.cam.ac.uk/New+Museums+Site (location of the New Museums Site)
- http://map.cam.ac.uk/saint (everything containing 'saint', multiple hits)
- http://map.cam.ac.uk/saint%20johns%20street ('St John's Street', note lower case, 'saint' vs. 'st', omitted apostrophe, and %20 for space)
There's an extended search syntax, for example
- http://map.cam.ac.uk/?q=dow&partial=partial (everything containing words starting 'do')
- http://map.cam.ac.uk/?q=saint&filter=college (all colleges with 'saint' in their names, but not roads or anything else)
...or based on underlying OSM identifiers, which are Planon IDs for University buildings.
- http://map.cam.ac.uk/?ref=M038 (The Austin Building - note that's a Planon ID)
- http://map.cam.ac.uk/?ref=STEDMUNDS019 (St Endmund's building 019 - extended ID scheme for non-University buildings)
...or on map institution identifiers:
- http://map.cam.ac.uk/?inst=CS (the UCS, by INSTID)
...or based on physical areas
- http://map.cam.ac.uk/?bb=52.2043,0.11835,52.2025,0.1216 (New Museums Site)
Embedding Maps
All of the URL's above can be used as the source for an iframe to embed the corresponding map in a particular page - see The Embedding API for details.
These examples use tiles from http://map.cam.ac.uk/ - because it currently requires Raven authentication they won't work properly until you've authenticated (once) to map.cam.ac.uk.
For example this:
<!DOCTYPE html> <html> <head> <title>Iframe test</title> <style type="text/css"> #map { width: 400px; height: 400px; border: 1px solid black; } </style> </head> <body> <iframe id="map" src="http://map.cam.ac.uk/Computing+Service"> </iframe> </body> </html>
Produces a page like this.
Here's a further example: the normal UCS 'Where we are' page reworked to use the new map.
Tile API
The tiles making up the map are freely available - see The Tile API.
These examples use tiles from http://map.cam.ac.uk/ - because it currently requires Raven authentication they won't work properly until you've authenticated (once) to map.cam.ac.uk.
Here are some of the tiles that make up the city centre.
They follow the conventions of Open Street Map and other similar systems and so can be consumed in various ways. Here are some examples using third-party map APIs:
- An example displaying our tiles, OSM's, or Google's using OpenLayers.
- An example with marker and shape overlay using Leaflet
- A further example combining our tiles and Google's, this time using the Google Maps API
Index API
There's an API for accessing the data in the map's index - see The Database API. It uses similar queries to those used to draw and embed maps and returns results in JSON format. To ease experimentation you can add '&debug=1' to all index API queries to have results displayed in a browser rather than exported as JSON files. Here are some examples based on the map URLs above:
- http://map.cam.ac.uk/v5.json?q=Computing+Service (debug version)
- http://map.cam.ac.uk/v5.json?q=New+Museums+Site (debug version)
- http://map.cam.ac.uk/v5.json?q=saint (debug version)
- http://map.cam.ac.uk/v5.json?q=saint%20johns%20street (debug version)
- http://map.cam.ac.uk/v5.json?q=dow&partial=partial (debug version)
- http://map.cam.ac.uk/v5.json?q=saint&filter=college (debug version)
- http://map.cam.ac.uk/v5.json?ref=M038 (debug version)
- http://map.cam.ac.uk/v5.json?ref=STEDMUNDS019 (debug version)
- http://map.cam.ac.uk/v5.json?inst=CS (debug version)
- http://map.cam.ac.uk/v5.json?bb=52.2021,0.1184,52.2047,0.1218 (debug version)