MapView.Snapshot
----------------

Creates a map snapshot.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [MapView](component_MapView.md) | [9.0](newinversion90.md) | ✅ Yes | ❌ No | ❌ No | ✅ Yes, on macOS | ✅ Yes |

MBS( "MapView.Snapshot"; Options { ; ImageType; FileName } ) 

**MBS**( **"MapView.Snapshot";** /\* Creates a map snapshot. \*/  
**$Options**; /\* The options as JSON block.  
All values are optional and have default.e.g. "{\\"width\\": 800, \\"height\\": 600}" \*/   
**$ImageType**; /\* Optional; The type of image to return.   
Either JPEG, PNG, GIF or BMP. Default is JPEG.e.g. "JPEG" \*/   
**$FileName**) /\* Optional; The filename to use for the picture.  
Default is "image" with the extension matching the image type.e.g. "test.jpg" \*/ 

### 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:  
| width | The pixel width requested. Default is 256. |
|---|---|
| height | The pixel height requested. Default is 256. |
| scale | The scale of the display, defaults to screen scale. Only for iOS. |
| showsPointsOfInterest | Whether to show points of interests. Pass 1 to enable or 0 to disable. |
| showsBuildings | Show buildings. Pass 1 to enable or 0 to disable. |
| mapType | Pass Standard, Satellite, Hybrid, SatelliteFlyover, HybridFlyover or MutedStandard. |
| mapRect | An object with x, y, width and height for the map rectangle to show in world coordinates. |
| region | An 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. |
| camera | The JSON object for camera specification. |
| appearance | Which 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](JSONCreateObjectRef.md)" ) \]   
Set Variable \[ $r ; Value: MBS ( "[JSON.AddNumberToObject](JSONAddNumberToObject.md)"; $json ; "width"; 800 ) \]   
Set Variable \[ $r ; Value: MBS ( "[JSON.AddNumberToObject](JSONAddNumberToObject.md)"; $json ; "height"; 600 ) \]   
Set Variable \[ $r ; Value: MBS ( "[JSON.AddStringToObject](JSONAddStringToObject.md)"; $json ; "mapType"; "HybridFlyover" ) \]   
Set Variable \[ $r ; Value: MBS ( "[JSON.AddNumberToObject](JSONAddNumberToObject.md)"; $json ; "showsBuildings"; 1 ) \]   
Set Variable \[ $r ; Value: MBS ( "[JSON.AddNumberToObject](JSONAddNumberToObject.md)"; $json ; "showsPointsOfInterest"; 1 ) \]   
\#   
Set Variable \[ $camera ; Value: MBS ( "[JSON.CreateObjectRef](JSONCreateObjectRef.md)" ) \]   
\# The coordinate point on which the map should be centered.   
Set Variable \[ $r ; Value: MBS ( "[JSON.AddNumberToObject](JSONAddNumberToObject.md)"; $camera ; "latitude"; 40.7457172 ) \]   
Set Variable \[ $r ; Value: MBS ( "[JSON.AddNumberToObject](JSONAddNumberToObject.md)"; $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](JSONAddNumberToObject.md)"; $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](JSONAddNumberToObject.md)"; $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](JSONAddNumberToObject.md)"; $camera ; "heading"; 28 ) \]   
\#   
Set Variable \[ $r ; Value: MBS ( "[JSON.AddItemToObject](JSONAddItemToObject.md)"; $json ; "camera"; $camera ) \]   
Set Variable \[ $r ; Value: MBS ( "[JSON.Release](JSONRelease.md)"; $camera ) \]   
\#   
Set Variable \[ $options ; Value: MBS ( "[JSON.Format](JSONFormat.md)"; $json ) \]   
Set Variable \[ $r ; Value: MBS ( "[JSON.Release](JSONRelease.md)"; $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

- [IsError](IsError.md)
- [JSON.AddItemToObject](JSONAddItemToObject.md)
- [JSON.AddNumberToObject](JSONAddNumberToObject.md)
- [JSON.AddStringToObject](JSONAddStringToObject.md)
- [JSON.CreateObject](JSONCreateObject.md)
- [JSON.CreateObjectRef](JSONCreateObjectRef.md)
- [JSON.Format](JSONFormat.md)
- [JSON.Release](JSONRelease.md)

### Example Databases

- [Mac and iOS/MapKit/MapKit Snapshots](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/MapKit/MapKit%20Snapshots.shtml#1ScriptAnchor_)

### Blog Entries

- [Apple Maps in FileMaker on iOS](https://www.mbsplugins.de/archive/2019-01-23/Apple_Maps_in_FileMaker_on_iOS/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.0pr8](https://www.mbsplugins.de/archive/2019-01-15/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 1/2022, Seite 28](https://filemaker-magazin.de/neuigkeit/4172-Appetithappen-FMM_202201)

This function checks for a license.

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

  
[MapView.ShowAllAnnotations](MapViewShowAllAnnotations.md) - [MarkDown.CSS](MarkDownCSS.md)

[HTML Version](MapViewSnapshot.shtml)