Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

MapView.Snapshot

Creates a map snapshot.

Component Version macOS Windows Linux Server iOS SDK
MapView 9.0 ✅ Yes ❌ No ❌ No ✅ Yes, on macOS ✅ Yes
MBS( "MapView.Snapshot"; Options { ; ImageType; FileName } )   More

Parameters

Parameter Description Example Flags
Options The options as JSON block.
All values are optional and have default.
"{\"width\": 800, \"height\": 600}"
ImageType The type of image to return.
Either JPEG, PNG, GIF or BMP. Default is JPEG.
"JPEG" Optional
FileName The filename to use for the picture.
Default is "image" with the extension matching the image type.
"test.jpg" Optional

Result

Returns image or error.

Description

Creates a map snapshot.
Not sure if this works on server!

Keys in the JSON include:
widthThe pixel width requested. Default is 256.
heightThe pixel height requested. Default is 256.
scaleThe scale of the display, defaults to screen scale. Only for iOS.
showsPointsOfInterestWhether to show points of interests. Pass 1 to enable or 0 to disable.
showsBuildingsShow buildings. Pass 1 to enable or 0 to disable.
mapTypePass Standard, Satellite, Hybrid, SatelliteFlyover, HybridFlyover or MutedStandard.
mapRectAn object with x, y, width and height for the map rectangle to show in world coordinates.
regionAn object with region details. Can be degree or meter based for span. latitude and longitude to define center coordinate. Add latitudeMeters/longitudeMeters or latitudeDelta/longitudeDelta to define span.
cameraThe JSON object for camera specification.
appearanceWhich appearance to use for MacOS 10.14. Can be Dark, Light or current. Default is current of Mac.

Camera specification includes center coordinate (latitude and longitude) and can be either looking from eye point (eyeLatitude, eyeLongitude and altitude) or looking from distance (distance, pitch and heading).

Rendering may take a few seconds, but gets faster over time due to caching.

Examples

Make a snapshot with all options default:

Set Field [ Snapshots::Image ; MBS( "MapView.Snapshot"; "{}" ) ]

Snapshot with camera:

Set Variable [ $json ; Value: MBS( "JSON.CreateObjectRef" ) ]
Set Variable [ $r ; Value: MBS( "JSON.AddNumberToObject"; $json; "width"; 800 ) ]
Set Variable [ $r ; Value: MBS( "JSON.AddNumberToObject"; $json; "height"; 600 ) ]
Set Variable [ $r ; Value: MBS( "JSON.AddStringToObject"; $json; "mapType"; "HybridFlyover" ) ]
Set Variable [ $r ; Value: MBS( "JSON.AddNumberToObject"; $json; "showsBuildings"; 1 ) ]
Set Variable [ $r ; Value: MBS( "JSON.AddNumberToObject"; $json; "showsPointsOfInterest"; 1 ) ]
#
Set Variable [ $camera ; Value: MBS( "JSON.CreateObjectRef" ) ]
# The coordinate point on which the map should be centered.
Set Variable [ $r ; Value: MBS( "JSON.AddNumberToObject"; $camera; "latitude"; 40.7457172 ) ]
Set Variable [ $r ; Value: MBS( "JSON.AddNumberToObject"; $camera; "longitude"; -73.9941266 ) ]
#
# The line-of-sight distance from the camera to the center coordinate of the map.
Set Variable [ $r ; Value: MBS( "JSON.AddNumberToObject"; $camera; "distance"; 3000 ) ]
#
# The viewing angle of the camera, measured in degrees.
# A value of 0 results in a camera pointed straight down at the map. Angles greater than 0 result in a camera that is pitched toward the horizon by the specified number of degrees. If the map type is satellite or hybrid, the pitch value is clamped to 0.
# The value in this property may be clamped to a maximum value to maintain map readability. There is no fixed maximum value, though, because the actual maximum value is dependent on the current altitude of the camera.
Set Variable [ $r ; Value: MBS( "JSON.AddNumberToObject"; $camera; "pitch"; 70 ) ]
#
# The heading of the camera (measured in degrees) relative to true north.
# The value 0 means that the top edge of the map view corresponds to true north. The value 90 means the top of the map is pointing due east. The value 180 means the top of the map points due south, and so on.
Set Variable [ $r ; Value: MBS( "JSON.AddNumberToObject"; $camera; "heading"; 28 ) ]
#
Set Variable [ $r ; Value: MBS( "JSON.AddItemToObject"; $json; "camera"; $camera) ]
Set Variable [ $r ; Value: MBS( "JSON.Release"; $camera ) ]
#
Set Variable [ $options ; Value: MBS( "JSON.Format"; $json ) ]
Set Variable [ $r ; Value: MBS( "JSON.Release"; $json ) ]
Set Variable [ $image ; Value: MBS("MapView.Snapshot"; $options; "PNG"; "map.png") ]
If [ MBS("isError") ]
    Show Custom Dialog [ "Failed to render map" ; $image ]
Else
    Set Field [ Snapshots::Image ; $image ]
End If

See also

Example Databases

Blog Entries

This function checks for a license.

Created 12nd January 2019, last changed 29th September 2020


MapView.ShowAllAnnotations - MarkDown.CSS