This module contains a widget to display a map based on OpenStreetMap data, plus additional markers and GPS tracks. The widget allows zooming and paning with the mouse, as well as programatically. There is a tutorial on how to use this widget, it is available here.
The map widget displays a map as a collection of tiles, each tile is a square bitmap 256 pixels in width and height. These tiles are downloaded from tile servers as needed and they are stored locally in a persistent cache on disk. The Open Street Map tile server is always available, and it is used by the map widget by default. In addition tiles from the Thunderforest service can also be used, but this requires an API key to be set. If you have an API key, and you can get a developer one for free, set the AL2TFAPIKEY environment variable to contain the API key. The API key is compiled into the code and the environment variable is not needed if you distribute a built application using the map widget.
The map widget can overlay GPS tracks onto the map. These are sequences of GPS points, which represent a continuous track: the map widget will draw aa single line connecting all the points. Multiple tracks can be added to the map and all would be drawn independently.
GPS tracks can form groups. A group is a number of symbol which is specified to add-track method. Groups are useful because the map widget allows specifying how the track is drawn (the pen%) as well as the Z-order at group level. A group can be used to draw a GPS track that is discontinous.
|(require map-widget)||package: map-widget|
Construct a new widget. position specifies the initial position shown in the center of the map, it is a vector containing the latitude and longitude. If position is #f, a defatult position will be used.Set the zoom level for the displayed map. The zoom level is a value between 1 (zoomed out) and 16 (zoomed in). The zoom level can also be changed by the user using the mousewheel, so once set, it is not guaranteed to remain at the same valueReturn the current zoom level for the map.Remove all overlay items (tracks and markers) from the widgetAdd a new GPS track to the map. The GPS track is a sequence of points, each point is a vector of at least two elements: the latitude and longitude of the point.
A track can be addded to a group, which is a symbol used to identify related tracks. The pen% and z-order can be specified for a group.Add a marker to the map at the specified position. "name" will be used for the labelDisplay a cicle marker at the specified GPS point. The marker can be moved around by calling this method with a new position or it can be cleared by specifying #f as the locationIf flag is #t, the map will be automatically panned so that the location speficied by set-current-location is always in the middle of the map, when flag is #f, this functionality is disabledSet the pen used to draw tracks in the specified track group. When the track group is #f, the default pen is updated, this is used for tracks that have no group defined (i.e. the group is #f)Set the order in which tracks in the specified trackgroup will be drawn. Tracks with a smaller Z-order will be drawn before tracks with a larger Z-order. The draw order for tracks with the same Z-order value is unspecified.Delete all GPS tracks within the specified groupCenter the map around the specified track group, or around all tracks if group is #fCenter the map around the specified position, a vector containing the latitude and longitudeCenter and set the zoom level of the map such that the specified track group fits on the visible part of the map canvas. If group is #f, all the tracks will fit on the map canvas
By default only the Open Street Map tile server is available. To use Thunderforest tiles, you will need to obtain an API key and set the AL2TFAPIKEY environment variable with that API key.
When this function is called, the selected tile provider is also stored int the racket preference file and this tile provider will be used each time the application is run, util this function is called with a different tile provider name