Chapter 9. Mapping

Table of Contents
ii_maps.js
ii_maps_callbacks
ii_maps_utilities.js

The ii_maps.js library provides a basis for mapping applications. It implements abstractions called atlases, mapsets and levels to represent collections of maps at different levels of detail. There is more detail on these concepts in the separate mapping documentation.

Additionally, the library provides simple methods for moving between maps without knowing the details of the maps available.

ii_maps.js

current_mapset

The mapset from which the current map was selected.

current_level

The level from which the current map was selected.

current_cx current_cy current_w current_h

The centre and area covered by the currently displayed map, in real world coordinates.

maps_init(thumbnail_applet, scale_location)

Picks an initial map and displays it. The arguments are optional. If thumbnail_applet is given it should be an Easel applet which will display a smaller map with a rectangle showing a larger area. If scale_location is given it should either be an HTML image object which will be used to display a scale for the map (if available) or a string number,number giving a position in the applet where the scale will be overlaid on the map.

mapset = maps_mapset_named(name)

Looks through all loaded atlases for the mapset named name.

maps_goto(cx, cy, width, height)

Select the best map to show the given area from the current atlas and load it.

maps_goto_delta(dx, dy)

Scrolls to a map at a position relative to the current one given by dx and dy. The parameters are given as proportions of the current maps' size. For instance passing 0.5 for dx will move half a map width East.

maps_lookfor_delta(dx, dy)

Checks if a maps_goto_delta call with those arguments would fetch a different map. Can be used to grey out scroll buttons etc.

maps_zoomin()

Get a more detailed map. If a rectangle has been dragged on the map, try to zoom to show that area as well as possible, otherwise zoom into the centre of the map.

maps_zoomout()

Get a map of a wider area.

maps_level_down()

Returns the next level of maps down, or null if we are on the lowest level.

maps_level_up()

Returns the next level of maps up, or null if we are on the highest level.

mapdescription = maps_remember()

Return a magic string which names the current map and which can be used to come back to it using maps_recall.

maps_recall(mapdescription)

Goes back to the map named by mapdescription which was previously returned by maps_remember.

maps_select_atlas(atlas)

Switch to this atlas.

maps_select_atlas_byname(name)

Switch to the named atlas.

maps_select_default_atlas()

Switch to the first loaded atlas.