MapView.AddPolygon
------------------

Adds a polygon to the map.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [MapView](component_MapView.md) | [9.4](newinversion94.md) | ✅ Yes | ❌ No | ❌ No | ❌ No | ✅ Yes |

MBS( "MapView.AddPolygon"; MapView; JSON ) 

**MBS**( **"MapView.AddPolygon";** /\* Adds a polygon to the map. \*/  
**$MapView**; /\* The map view reference number.e.g. $$MapView \*/   
**$JSON**) /\* The JSON to describe the circle. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| MapView | The map view reference number. | $$MapView |
| JSON | The JSON to describe the circle. |  |

### Result

Returns identifier or error.

### Description

Adds a polygon to the map.  
The JSON may contain the following entries:  
| coordinates | The JSON array with the objects for the coordinates. Each entry can contain either longitude &amp; latitude pair, x and y pair or address value. |
|---|---|
| title | The title for the polygon. |
| subtitle | The subtitle for the item. |
| fillColor | The fill color as name or hex notation for the polygon. |
| strokeColor | The stroke color as name or hex notation for the polygon. |
| identifier | The identifier to use. Can be empty to get new identifier auto assigned. |
| lineWidth | The line width to use. Default 5 point. |

  
You can either pass latitude and longitude together or pass the address and we lookup it to find coordinates.  
### Examples

Add polygon from Hamburg to Munich and Cologne:

 Set Variable \[ $r ; Value: MBS ( "MapView.AddPolygon"; $$MapView ; "{ \\"coordinates\\": \[{\\"address\\": \\"Hamburg, Germany\\"}, {\\"address\\": \\"Munich, Germany\\"}, {\\"address\\": \\"Cologne, Germany\\"}\], \\"strokeColor\\": \\"#FF000077\\" }") \]  
Add polygon with some coordinates:

 Set Variable \[ $r ; Value: MBS ( "MapView.AddPolygon"; $$MapView ; "{   
 \\"coordinates\\":   
\[  
{\\"longitude\\": 7.3 , \\"latitude\\": 50.4 },   
{\\"longitude\\": 7.3 , \\"latitude\\": 50.5 },   
{\\"longitude\\": 7.4 , \\"latitude\\": 50.5 },   
{\\"longitude\\": 7.4 , \\"latitude\\": 50.4 }  
\],  
 \\"strokeColor\\": \\"#FF000077\\"  
}")\]  
### See also

- [MapView.AddPolyline](MapViewAddPolyline.md)

### Release notes

- **Version 9.5**
    - Added strokeColor and fillColor properties for [MapView.AddPolygon](http://www.mbsplugins.eu/MapViewAddPolygon.shtml) and [MapView.AddPolyline](http://www.mbsplugins.eu/MapViewAddPolyline.shtml) functions.
- **Version 9.4**
    - Added [MapView.AddPoint](http://www.mbsplugins.eu/MapViewAddPoint.shtml), [MapView.AddPolyline](http://www.mbsplugins.eu/MapViewAddPolyline.shtml) and [MapView.AddPolygon](http://www.mbsplugins.eu/MapViewAddPolygon.shtml) functions.

### Example Databases

- [Mac and iOS/MapKit/MapView BeeExample](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/MapKit/MapView%20BeeExample.shtml#28ScriptAnchor_)
- [Mac and iOS/MapKit/MapView Click Polygons](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/MapKit/MapView%20Click%20Polygons.shtml#12ScriptAnchor_)

### Blog Entries

- [Neue Funktionen des MBS FileMaker Plugin 9.4](https://www.mbsplugins.de/archive/2019-10-05/Neue_Funktionen_des_MBS_FileMa/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.5pr1](https://www.mbsplugins.de/archive/2019-10-02/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.4pr7](https://www.mbsplugins.de/archive/2019-09-12/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 3/2022, Seite 27](https://filemaker-magazin.de/neuigkeit/4187-Appetithappen-FMM_202203)
- [Ausgabe 3/2022, Seite 25](https://filemaker-magazin.de/neuigkeit/4187-Appetithappen-FMM_202203)

This function is free to use.

Created 11st September 2019 , last changed 20th September 2019

  
[MapView.AddPoint](MapViewAddPoint.md) - [MapView.AddPolyline](MapViewAddPolyline.md)

[HTML Version](MapViewAddPolygon.shtml)