Color scheme: Light
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » Data views » WklMap

WklMap

WklMap shows where something happens on an Access form: sign-ins per city, sites, or customers, as points on a world map. Each record with a latitude and a longitude becomes a point whose area and color stand for a value. Like a subform, the map follows the form's current record through LinkMasterFields and LinkChildFields. The map data is built into the component, so the map works offline and in closed networks and never sends what the user looks at to a map service.

Since release 1.63.0; part of the world, zoom and a color field of its own since 1.68.1.

Get started

Put the control on a form (Form Design › Controls › ActiveX Controls › WKL Map), then set the data in the property sheet or in Form_Load:

Private Sub Form_Load()
    With Me!Map1.Object
        .RecordSource = "qrySignInsPerCity"
        .LatitudeField = "Latitude": .LongitudeField = "Longitude"
        .ValueField = "SignIns": .CaptionField = "City": .KeyField = "CityID"
    End With
End Sub

Common tasks

  • Show the sign-ins of the selected customer per city: RecordSource = the sign-ins per city with their coordinates, LinkMasterFields = the customer key on the form, LinkChildFields = the customer key in the data.
  • Open the details of a city on click: handle PointClick(Key, Value); Key is the value of KeyField.
  • Show the values as a traffic light: MinColor = RGB(0, 160, 0), MidColor = RGB(255, 200, 0), MaxColor = RGB(200, 0, 0).
  • Show one region instead of the world: Extent = "5.5,45,17.5,55.5" (west, south, east, north in degrees, with a decimal point), or Extent = "auto" to frame the points.
  • Let the user look around: AllowZoom = True. To restore the user's view next time, store VisibleExtent in ExtentChanged and set it as Extent when the form opens.
  • Show a second value as the color, for example the share of failed sign-ins: ColorField = "FailedShare", ColorRange = "0,1", ColorFormat = "0%".
  • Leave out country borders, for example for customers in regions with disputed borders: ShowBorders = False.
  • Find rows that couldn't be placed: RowsWithoutPosition after DataLoaded.

Visual aid

+- WklMap -------------------------------------------------------+
|                          Sign-ins                              | 1
|        ____________________________________________            |
|      /    .-~~-.          __    ___                   \        | 2
|     |    (      )   .   (  )o (   )   .-~~~-.           |       |
|     |     `-..-'      O  `-'  ( (  ))  (       )         |      | 3
|     |        \       o     (    )      `-...-'    o     |       | 4
|      \        )                                        /        |
|        `-------------------------------------------'          |
+----------------------------------------------------------------+
RegionMeaning
1Title
2The edge of the world in the Equal Earth projection
3A point with a large value: larger area, color near MaxColor
4A point with a small value: smaller area, color near MinColor, drawn on top of larger points

Key features

  • Data binding to a table, query, or SQL statement: one point per record with a latitude and a longitude in degrees, an optional value, caption, and key.
  • Follows the form like a subform through LinkMasterFields and LinkChildFields; when the master record changes, the map reads its data again.
  • Area and color from the value: the area of a point is proportional to its value, and its color blends from MinColor to MaxColor, optionally through MidColor. A second field can set the color, with the range of the loaded values or a fixed one.
  • Part of the world and zoom: the world, the points, or a region in degrees; with AllowZoom the user zooms with the mouse wheel and the keyboard and pans by dragging. A region is drawn with finer borders (Natural Earth 1:50m).
  • No map service: the countries come from Natural Earth (public domain), built into the component; the map works without an internet connection.
  • Same picture everywhere: Form view, Design view (with sample points), Print Preview, and reports.
  • Readable for everyone: a tooltip with caption and value, a list of the points for screen readers (largest value first), and the same color schemes as the other components, including high contrast.

Core concepts

Areas are true. The map uses the Equal Earth projection (Šavrič, Patterson, Jenny, 2018), which keeps areas in proportion. A point in Norway and one in Kenya are compared fairly, which a rectangular map would distort toward the poles. The area of a point grows with its value: four times the value gives twice the diameter. The largest value gets MaxPointSize; no point is smaller than MinPointSize, so a point is always visible and clickable.

Small points stay visible. Large points are drawn first and small points on top. A click finds the point that is drawn on top.

A wrong position doesn't hide the map. A row whose latitude or longitude is missing, not a number, or out of range isn't drawn; it's counted in RowsWithoutPosition. Latitude 0 with longitude 0 is a real place (in the Gulf of Guinea) and is drawn; store Null for an unknown position.

Borders are a statement. Country borders follow Natural Earth's view of the de facto situation, including disputed areas. If your application must not show borders, set ShowBorders = False; the land is then drawn in one piece. The world is drawn at 1:110m, a continent, a country or a region at 1:50m. Very small island states are tiny or missing even then, so a point is always drawn at its own coordinates and never moved onto a country.

The user's zoom is a view, not a setting. Extent is what the form shows; the user's zoom changes only the window and is not saved. It stays when the data are read again (Requery, another master record), so the user keeps the region they are looking at, and it ends when code sets Extent. A report and Print Preview always show Extent. Extent uses a decimal point whatever the regional settings and never crosses longitude 180, the left and right edge of the map.

Errors are displayed, not raised. The map reads its data on its own (when the form opens and when the master record changes), outside any VBA call that could catch an error. A read error is drawn in the map, stored in LastError, and reported through DataLoaded.

Contract

MemberMeaning
RecordSourceTable, query or SQL statement.
LatitudeField, LongitudeFieldDegrees north (-90 to 90) and east (-180 to 180).
ValueFieldSets the area, and the color without ColorField; empty for points of equal size.
CaptionField, KeyFieldCaption in the tooltip and for screen readers; key reported by PointClick (row number when empty).
Title, ValueFormatTitle above the map; .NET number format of the value in the tooltip, for example #,##0.
MinPointSize, MaxPointSizeDiameter in points (1/72 inch): 2 to 72 (default 5) and 2 to 144 (default 30).
MinColor, MidColor, MaxColorColors of the smallest, middle and largest value; MidColor = -1 (default) for a straight blend.
ShowBordersCountry borders (default on).
Extentworld (default), auto (the points) or west,south,east,north in degrees with a decimal point.
VisibleExtentThe part shown now, after the user's zoom; read only.
AllowZoomZoom and pan by the user in Form view (default off).
ColorField, ColorRange, ColorFormatField of the color value (empty: ValueField); fixed range low,high (empty: the loaded values); its format in the tooltip.
LinkMasterFields, LinkChildFieldsFields or controls of the form and the matching fields of the data, separated by semicolons.
RequeryReads the data again.
PointCount, RowsWithoutPosition, LastError, MapSourceRead only; MapSource names the data set drawn now.
ColorSchemeAs for the other components.
EventWhen
PointClick(Key, Value)A click on a point.
DataLoaded(Points)The data were read; also after an error (see LastError).
ExtentChanged(Extent)The user zoomed or panned; Extent is the part now shown.

Administration

Troubleshooting

None yet.

For developers

  • WklChart: values over time or per category, where the map shows them by place.
en/wiki/msaccess/comctl/data-views/map/start.txt · Last modified: by Wolfgang van der Stille