Map Module

From Planimate Knowledge Base
Revision as of 21:06, 20 March 2012 by Rick (talk | contribs)
Jump to navigation Jump to search

The Map Module is a demo model,  MapDemo, available to registered users on idBase in the Planimate / Developer Tools region. It demonstrates use of the Map_Paint_Object,  a sophisticated and high performance zoomable/scrollable tiled map display. The Map Paint Object works with support of a number of Planimate routine operations, system broadcasts, object properties, table structures and system attributes. This model is a working example of how to tie it all together.

Configuration Table: t.module_options

This table has a single row with settings that configure the map behaviour.

mapObject
This needs to be set to a _paint_objects label which points to the map paint object.
FixedZoom

Boolean, if false the map works in variable zoom mode where the model specifies the longitude range and the map calculates the appropriate zoom.

If true, the map works in fixed zoom mode where the model specifies a co-ordinate and zoom level and the map calculates the longitude range.

Fixed zoom is generally best and required if you wish the map to track the mouse cursor position as you zoom in and out.

TileSet

A text cell (can be a label if required) which names the tileset. The map will look for tiles in a folder of this name or a DB file of that name if the Map Paint Object's "Fetch Tiles From DB File" option is set.

Shipping models using tiles in a DB file is recommended.

MinZoom

The minimum zoom level (most zoomed out level) that the user can zoom out to. 0 is the "world" level where one 256x256 tile is the whole world, but since a map view is typically bigger than a tile, it would very likely be more like 2 or 3 for the whole world.

In a model focussed on a region you want the minimum zoom level set so the whole region is covered and not much more.

MaxZoom

The maximum zoom level (most zoomed in level) that the user can zoom in to. This depends on how many zoom levels of tiles you supply which will in turn depend on the level of geographic detail the model requires.

Planimate will upscale tiles if the map option is enabled. This means you can have detailed tiles at multiple specific regions and coarser tiles at other, the platform combines the best it can get at any particular location.

ZoomToCursor

If this boolean is false then the map zooms in and out based on keeping the last clicked location centred in the view.

If true then the map zooms in and out in a way that keeps the location the cursor at under the cursor.

Be aware that if the user zooms out too far, the map will clip to the edges and the position under the cursor will change and then zooming in will zoom in to a different location. You could fix this by either setting a MinZoom or extending the map code to not track the cursor when the zoom value is lower than a threshold.

MinIconScale, MaxIconScale

Values which should be set as percentages. The demo includes basic scaling of item and portal icons so their size grows and shrinks in proportion to the level of zoom of the map. In detailed models this can keep objects such as berths and ships in proportion with their surrounding geography.

These values set the minimum and maximum scale factor ranges, defaults being 25% for minimum and 400% for maximum.

In a complex model you may have different scales for different features (eg: berths vs. ships) and you will need to extend the handler code for this.

MinIconLevel

This sets the minimum zoom level which icons (object and item) are displayed. If the map zoom level is less than this value, the icons are hidden, something you may want when zooming out.

As with the scaling, in a complex model you might customise this to have various levels of minimum zoom for different features.

UnityScaleLevel

A value which sets the zoom level at which the object/item icons in this demo are at a proportion of 1 object/item pixel to 1 map tile pixel.

In a model where the object and item items are to line up accurately with map features, this value may well need to differ for the different locations and items and you would need to extend the map code to handle each case separately.

Such an extention could also incorporate loading different icons at different levels of zoom as scaling the one icon up or down too much does not give the best results.