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

MapView.AddPoint

Adds a point or pin to the map.

Component Version macOS Windows Linux Server iOS SDK
MapView 9.4 ✅ Yes ❌ No ❌ No ❌ No ✅ Yes
MBS( "MapView.AddPoint"; MapView; JSON )   More

Parameters

Parameter Description Example
MapView The map view reference number. $$MapView
JSON The JSON to describe the point.

Result

Returns identifier or error.

Description

Adds a point or pin to the map.
The JSON may contain the following entries:
latitudeThe latitude of the coordinate.
longitudeThe longitude of the coordinate.
addressThe address to lookup to find latitude or longitude.
radiusThe radius in meter.
titleThe title for the pin.
subtitleThe subtitle for the item.
colorThe color as name or hex notation for the pin.
identifierThe identifier to use. Can be empty to get new identifier auto assigned.
imageThe base64 encoded image data to use.
imageWidthOptional the image width to use.
imageHeightOptional the image height to use.
clusteringIdentifierOptionally an identifier that determines whether the annotation view participates in clustering.
displayPriorityOptionally the display priority of this annotation view. Can be Required, High, Low or Default.

New in 9.5 are some boolean keys named enabled, draggable and canShowCallout to customize behavior.

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

Examples

Create MBS Pin on map with custom image:

Set Variable [ $json ; Value: "{ \"address\": \"Nickenich\", \"title\": \"Monkeybread Software\", \"subtitle\": \"MBS is here\", \"imageWidth\": 40, \"imageHeight\": 40 }" ]
# add image from container field to JSON
Set Variable [ $json ; Value: MBS( "JSON.AddStringToObject"; $json; "image"; Base64Encode ( MapView::image ) ) ]
# show
Set Variable [ $r ; Value: MBS( "MapView.AddPoint"; $$MapView; $JSON) ]

Adds simple pin for Hamburg:

Set Variable [ $r ; Value: MBS( "MapView.AddPoint"; $$MapView; "{ \"address\": \"Hamburg, Germany\", \"title\": \"Hamburg\"}") ]

Create circle of pins around current region:

# create some pins on a circle around a given point
Set Variable [ $centerLat ; Value: MBS( "MapView.GetCenterCoordinateLatitude"; $$MapView ) ]
Set Variable [ $centerLon ; Value: MBS( "MapView.GetCenterCoordinateLongitude"; $$MapView ) ]
#
# loop counting up from 1 to $count
Set Variable [ $count ; Value: 12 ]
Set Variable [ $index ; Value: 1 ]
If [ $index$count ]
    Loop
        # your script steps here
        Set Variable [ $angle ; Value: 360 * ($index / 12) ]
        Set Variable [ $a ; Value: $angle / 180 * Pi ]
        #
        # calculate new coordinates
        Set Variable [ $fLat ; Value: ,005 ]
        Set Variable [ $fLon ; Value: ,01 ]
        Set Variable [ $lat ; Value: $centerLat + Sin($a) * $fLat ]
        Set Variable [ $lon ; Value: $centerLon + Cos($a) * $fLon ]
        #
        Set Variable [ $json ; Value: "{}" ]
        Set Variable [ $json ; Value: MBS( "JSON.AddNumberToObject"; $json; "latitude"; $lat ) ]
        Set Variable [ $json ; Value: MBS( "JSON.AddNumberToObject"; $json; "longitude"; $lon ) ]
        Set Variable [ $json ; Value: MBS( "JSON.AddNumberToObject"; $json; "clusteringIdentifier"; "pin") ]
        Set Variable [ $r ; Value: MBS( "MapView.AddPoint"; $$MapView; $JSON ) ]
        #
        # next
        Set Variable [ $index ; Value: $index + 1 ]
        Exit Loop If [ $index > $count ]
    End Loop
End If

See also

Release notes

Example Databases

Blog Entries

This function is free to use.

Created 10th September 2019, last changed 9th April 2020


MapView.AddPinWithAddress - MapView.AddPolygon