MapDraw

Description: Draws a "slippy" map, showing a list of site tags as pins on that map.
Returns: Object reference
Usage: Steady State only. (called from a GUITransform)
Function Groups: Graphics
Related to: SlippyMapRemoteTileSource1 | GetSessionContainers
Format: \MapDraw([Latitude, Longitude, Sites, InitZoom, MinZoom, MaxZoom])
Parameters:  
Latitude
Optional numeric expression specifying the Y-axis center of the map. If not provided, the calculated center of all sites to be drawn on the map will be used.
Longitude
Optional numeric expression specifying the X-axis center of the map. If not provided, the calculated center of all sites to be drawn on the map will be used. If there are no sites to display on the map, the initial display will be centered on North America.
Sites
Optional array of sites to display. Each site item in the array must be a structure, containing valid pointers for latitude, longitude and a callback object. See comments.
InitZoom
Optional numeric expression, specifying the initial zoom factor to use for the map. Ranges from 2 to 18. If not specified, the maximum zoom level (smallest area) that encompasses all the sites will be used.
MinZoom
Optional numeric expression, setting the lowest permitted zoom level (corresponding to the set of the largest tiles to be used, in the sense of maximum displayed area per tile).
MaxZoom
Optional numeric expression, setting the greatest permitted zoom level (corresponding to the set of the smallest tiles to be used, in the sense of minimum displayed area per tile).
UserInput
Optional Boolean. Set FALSE to disable user input. Affects only the map, not pins on the map. Defaults to TRUE.
DisableTools

Optional bit-wise value controlling which tools are disabled. Default to zero - all tools enabled.

(See: Bitwise Parameters & Operations)

Bit # Tool disabled
0 Zoom tools
1 Reset tool
2 Style tool
Reserved
Do not use.
Comments:

The zoom factor corresponds to the tile set that should be used within the area of the map. To zoom in or zoom out means switching to a tile set that shows a greater or lesser amount of detail, and therefore a corresponding smaller or larger area of geography.

Tiles are downloaded on request from the url specified in the property, SlippyMapRemoteTileSource1, found in Setup.INI file

If a sites array to be used, it is created by first making a call to GetSessionContainers. This returns an array of tag names to be used. This is used as the basis for a new array that contains structures for each site, build using the site's latitude, longitude and a call-back to a method for drawing the site. The structure of the array is defined as follows:

{***** Structure that holds information for drawing a Site on a map *****}
MapSite Struct [
   PtrLatitude  { Pointer to site's latitude in decimal degrees };
   PtrLongitude { Pointer to site's longitude in decimal degrees };
   Callback  { Scope where Draw(MapObj, Lat, Lon) is called to draw marker on map};
];

The following example shows how this would be done.

Examples:

Init [
  If 1 Main;
  [
    Sites = New(2);
    SiteObj = Scope(Code, "MySite1");
    Sites[0] = MapSite(&(SiteObj\Latitude), &(SiteObj\Longitude), SiteObj);
    SiteObj = Scope(Code, "MySite2");
    Sites[1] = MapSite(&(SiteObj\Latitude), &(SiteObj\Longitude), SiteObj);
  ]
]

Main [
  GUITransform(0, 400, 600, 0,
               1, 1, 1, 1, 1,
               0, 0, 1, 0,
               0, 0, 0,
               \MapDraw(Invalid, Invalid, Sites));
]

SiteObj is expected to have a Draw module. Draw is called by MapDraw to draw this site at its location on the map. Draw is called with the following parameters:

MapObj

Object value of MapDraw in which various helper functions can be called.

PtrLatitude

A pointer to the site’s latitude value.

PtrLongitude

A pointer to the site’s longitude value.

PtrHide

A pointer to a Boolean value. When true, the result should be that Draw will hide its graphic objects.

PtrZoomLevel

A pointer to the map's current zoom level, ranging from zero to twenty where zero shows the entire world.

Draw should use the helper functions LonToX() and LatToY(), to position its graphics at the correct x,y location on the map. For example:

X = MapObj\LonToX(PtrLongitude);
Y = MapObj\LatToY(PtrLatitude);