Platforms to show: All Mac Windows Linux Cross-Platform

Back to MKMapViewMBS class.

MKMapViewMBS.addAnnotation(annotation as MKAnnotationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Adds the specified annotation to the map view.
Example
Var mapview as MKMapViewMBS // your map view

// new pin
Var pin as new MKPointAnnotationMBS

pin.coordinate = mapView.centerCoordinate
pin.title = "Hello"

// show on map
mapView.addAnnotation pin

MKMapViewMBS.addAnnotations(annotations() as MKAnnotationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Adds an array of annotation objects to the map view.

Some examples using this method:

MKMapViewMBS.addOverlay(overlay as MKOverlayMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Adds a single overlay object to the map.
Example
Var mapview as MKMapViewMBS // your map view
Var centerCoordinate as CLLocationCoordinate2DMBS = mapview.centerCoordinate
Var radius as Integer = 300 // 300 meter

Var circle as MKCircleMBS = MKCircleMBS.circleWithCenterCoordinate(centerCoordinate, radius)
mapview.addOverlay circle

overlay: The overlay object to add. This object must conform to the MKOverlayMBS interface.

The specified object is added to the group of overlay objects in the MKOverlayLevelAboveLabels level. Adding an overlay causes the map view to begin monitoring the area represented by that overlay. As soon as the bounding rectangle of an overlay intersects the visible portion of the map, the map view adds a corresponding overlay view to the map. The overlay view is provided by the mapViewViewForOverlay event.

To remove an overlay from a map, use the removeOverlay method.

See also:

Some examples using this method:

MKMapViewMBS.addOverlay(overlay as MKOverlayMBS, level as integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Adds the overlay object to the map at the specified level.

overlay: The overlay object to add. This object must conform to the MKOverlayMBS interface.
level: The map level at which to place the overlay. For a list of possible values for this parameter, see level constants.

Positioning an overlay at a specific level places that overlay’s visual representation in front of or behind other map content such as map labels and point-of-interest icons.
This method adds the specified overlay to the end of the list of overlay objects at the given level. Adding an overlay also causes the map view to begin monitoring the area they represent. As soon as the bounding rectangle of the overlay intersects the visible portion of the map, the map view calls your rendererForOverlay event to get the renderer object to use when drawing the overlay.
To remove an overlay from a map, use the removeOverlay: method.

See also:

MKMapViewMBS.addOverlays(overlays() as MKOverlayMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Adds an array of overlay objects to the map.

overlays: An array of objects, each of which must conform to the MKOverlayMBS interface.

The specified objects are added to the group of overlay objects in the MKOverlayLevelAboveLabels level. Adding an overlay causes the map view to begin monitoring the area represented by that overlay. As soon as the bounding rectangle of the overlay intersects the visible portion of the map, the map view tries to draw the overlay. As soon as the bounding rectangle of an overlay intersects the visible portion of the map, the map view adds a corresponding overlay view to the map. The overlay view is provided by the mapViewViewForOverlay method of the map view's delegate object.

To remove multiple overlays from a map, use the removeOverlays method.

See also:

MKMapViewMBS.addOverlays(overlays() as MKOverlayMBS, level as integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Adds an array of overlay objects to the map at the specified level.

overlays: The array of overlay objects to add. Each object in the array must conform to the MKOverlayMBS interface.
level: The map level at which to place the overlays. For a list of possible values for this parameter, see MKOverlayLevel.

Positioning an overlay at a specific level places that overlay’s visual representation in front of or behind other map content such as map labels and point-of-interest icons.

This method adds the specified overlays to the end of the list of overlay objects at the given level. Adding the overlays also causes the map view to begin monitoring the area they represent. As soon as the bounding rectangle of an overlay intersects the visible portion of the map, the map view calls your rendererForOverlay event to get the renderer object to use when drawing that overlay.

To remove multiple overlays from a map, use the removeOverlays method.

See also:

MKMapViewMBS.annotations as MKAnnotationMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
The complete list of annotations associated with the receiver.

If no annotations are associated with the map view, the value of this property is empty.

MKMapViewMBS.annotationsInMapRect(mapRect as MKMapRectMBS) as MKAnnotationMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Returns the annotation objects located in the specified map rectangle.

mapRect: The portion of the map that you want to search for annotations.

Returns the array of annotation objects located in mapRect.

This method offers a fast way to retrieve the annotation objects in a particular portion of the map. This method is much faster than doing a linear search of the objects in the annotations property yourself.

MKMapViewMBS.annotationViews as MKAnnotationViewMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 20.4 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Queries internal list of MapView to get list of all annotation views.

MKMapViewMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Creates a new box view with size 100/100 and position 0/0
Example
Var x as new MKMapViewMBS

On success the handle property is not zero.

See also:

MKMapViewMBS.Constructor(Handle as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Creates an object based on the given NSView handle.
Example
Var t as new MKMapViewMBS(0, 0, 100, 100)
Var v as new MKMapViewMBS(t.handle)

MsgBox str(v.Bounds.Width)+" x "+str(v.Bounds.Height)

The handle is casted to a MKMapView and the plugin retains this handle.

See also:

MKMapViewMBS.Constructor(left as Double, top as Double, width as Double, height as Double)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Creates a new control with the given size and position.
Example
Var left,top,width,height as Integer
// define rectangle
Var x as new MKMapViewMBS(left, top, width, height)

On success the handle property is not zero.

See also:

MKMapViewMBS.convertCoordinateToPointToView(coordinate as CLLocationCoordinate2DMBS, view as NSViewMBS) as NSPointMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Converts a map coordinate to a point in the specified view.

coordinate: The map coordinate for which you want to find the corresponding point.
view: The view in whose coordinate system you want to locate the specified map coordinate. If this parameter is nil, the returned point is specified in the window's coordinate system. If view is not nil, it must belong to the same window as the map view.

Returns the point (in the appropriate view or window coordinate system) corresponding to the specified latitude and longitude value.

MKMapViewMBS.convertPointToCoordinateFromView(point as NSPointMBS, view as NSViewMBS) as CLLocationCoordinate2DMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Converts a point in the specified view's coordinate system to a map coordinate.

point: The point you want to convert.
view: The view that serves as the reference coordinate system for the point parameter.

Returns the map coordinate at the specified point.

MKMapViewMBS.convertRectToRegionFromView(rect as NSRectMBS, view as NSViewMBS) as MKCoordinateRegionMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Converts a rectangle in the specified view's coordinate system to a map region.
Example
// convert mouse position in x/y to select annotation on the given mouse point
Var xView As MKMapViewMBS = MapViewControl.View
Var rect As New NSRectMBS(x,y,1,1)
Var region As MKCoordinateRegionMBS = xView.convertRectToRegionFromView(rect,xView)
Var center As CLLocationCoordinate2DMBS = region.center
Var circle As New MKCircleMBS(center,32)
Var mapRect As MKMapRectMBS = circle.boundingMapRect()
Var xAnnos() As MKAnnotationMBS = xView.annotationsInMapRect(mapRect)

If xAnnos.LastRowIndex <> -1 Then
Var xThisAnno As MKAnnotationMBS = xAnnos(0)
If xThisAnno IsA MKPointAnnotationMBS Then
me.View.selectAnnotation(xThisAnno,False)
Return True
End If
End If

rect: The rectangle you want to convert.
view: The view that serves as the reference coordinate system for the rect parameter.

Returns the map region corresponding to the specified view rectangle.

MKMapViewMBS.convertRegionToRectToView(region as MKCoordinateRegionMBS, view as NSViewMBS) as NSRectMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Converts a map region to a rectangle in the specified view.

region: The map region for which you want to find the corresponding view rectangle.
view: The view in whose coordinate system you want to locate the specified map region. If this parameter is nil, the returned rectangle is specified in the window's coordinate system. If view is not nil, it must belong to the same window as the map view.

Returns the rectangle corresponding to the specified map region.

MKMapViewMBS.dequeueReusableAnnotationViewWithIdentifier(identifier as string) as MKAnnotationViewMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Returns a reusable annotation view located by its identifier.

identifier: A string identifying the annotation view to be reused. This string is the same one you specify when initializing the annotation view using the Constructor method.

Returns an annotation view with the specified identifier, or nil if no such object exists in the reuse queue.

For performance reasons, you should generally reuse MKAnnotationView objects in your map views. As annotation views move offscreen, the map view moves them to an internally managed reuse queue. As new annotations move onscreen, and your code is prompted to provide a corresponding annotation view, you should always attempt to dequeue an existing view before creating a new one. Dequeueing saves time and memory during performance-critical operations such as scrolling.

Some examples using this method:

MKMapViewMBS.deselectAnnotation(annotation as MKAnnotationMBS, animated as boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Deselects the specified annotation and hides its callout view.

annotation: The annotation object to deselect.
animated: If true, the callout view is animated offscreen.

MKMapViewMBS.Destructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
The destructor.

MKMapViewMBS.exchangeOverlay(index1 as Integer, index2 as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Exchanges the positions of the two overlay objects.

index1: The index of an overlay in the MKOverlayLevelAboveLabels map level.
index2: The index of another overlay in the MKOverlayLevelAboveLabels map level.

If you need to exchange overlays in other map levels, use the exchangeOverlay method.

See also:

MKMapViewMBS.exchangeOverlay(Overlay1 as MKOverlayMBS, Overlay2 as MKOverlayMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Exchanges the positions of the two overlay objects.

If the overlays are in the same map level, they exchange positions within that level’s array of overlay objects. If they are in different map levels, the two objects also swap levels. Swapping the position of the overlays affects their visibility in the map view.

See also:

MKMapViewMBS.insertOverlayAboveOverlay(overlay as MKOverlayMBS, aboveOverlay as MKOverlayMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Inserts one overlay object on top of another.

overlay: The overlay object to insert.
sibling: An existing object in the overlays array. This object must exist in the array and must not be nil.

This method inserts the overlay into the MKOverlayLevelAboveLabels level and positions it relative to the specified sibling. When displayed, this leads to the overlay's contents being displayed above that of its sibling. If sibling is not in the same map level, this method appends the overlay to the end of the list of overlays at the indicated level.

MKMapViewMBS.insertOverlayAtIndex(overlay as MKOverlayMBS, index as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Inserts an overlay object into the list associated with the map.

overlay: The overlay object to insert.
index: The index at which to insert the overlay object. If this value is greater than the number of objects in the overlays property, this method appends the object to the end of the array.

This method inserts the overlay into the MKOverlayLevelAboveLabels level.

See also:

MKMapViewMBS.insertOverlayAtIndex(overlay as MKOverlayMBS, index as integer, level as integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Inserts an overlay object into the level at the specified index.

overlay: The overlay object to insert.
index: The index at which to insert the overlay object. If this value is greater than the number of objects in the overlays property, this method appends the object to the end of the array.
level: The map level at which to place the overlay. For a list of possible values for this parameter, see level constants.

Inserting an overlay at a specific level places that overlay’s visual representation in front of or behind other map content such as map labels and point-of-interest icons.

See also:

MKMapViewMBS.insertOverlayBelowOverlay(overlay as MKOverlayMBS, belowOverlay as MKOverlayMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Inserts one overlay object below another.

overlay: The overlay object to insert.
sibling: An existing object in the overlays array. This object must exist in the array and must not be nil.

This method inserts the overlay into the MKOverlayLevelAboveLabels level and positions it relative to the specified sibling. When displayed, this leads to the overlay's contents being displayed beneath that of its sibling. If sibling is not in the same map level, this method appends the overlay to the end of the list of overlays at the indicated level.

MKMapViewMBS.mapRectThatFits(mapRect as MKMapRectMBS) as MKMapRectMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Adjusts the aspect ratio of the specified map rectangle to ensure that it fits in the map view’s frame.

mapRect: The initial map rectangle whose width and height you want to adjust.

Returns a map rectangle that is still centered on the same point of the map but whose width and height are adjusted to fit in the map view’s frame.

You can use this method to normalize map rectangle values before displaying the corresponding area. This method returns a new map rectangle that both contains the specified rectangle and fits neatly inside the map view’s frame.

See also:

MKMapViewMBS.mapRectThatFits(mapRect as MKMapRectMBS, edgePaddingLeft as Double, edgePaddingTop as Double, edgePaddingRight as Double, edgePaddingBottom as Double) as MKMapRectMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Adjusts the aspect ratio of the specified map rectangle, incorporating the specified inset values.

A map rectangle that is still centered on the same point of the map but whose width and height are adjusted to fit in the map view’s frame minus the inset values.

See also:

MKMapViewMBS.overlays as MKOverlayMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
The overlay objects currently associated with the map view.

This property contains the union of all overlays at the different levels of the map. The objects in this array must adopt the MKOverlayMBS interface. If no overlays are associated with the map view, the value of this property is an empty array.

The order of the objects in this array does not necessary reflect their visual order on the map.

Some examples using this method:

MKMapViewMBS.overlaysInLevel(level as Integer) as MKOverlayMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
The overlay objects in the specified level of the map.

level: The map level whose overlays you want. For a list of possible values for this parameter.

Returns an array of objects conforming to the MKOverlayMBS interfaces that display in the specified map level. If there are no overlays at the specified level, this method returns an empty array.

You can use this method to get all of the overlays assigned to a specific map level, which might be a subset of the complete set of overlay objects. For overlapping overlay objects, the order of objects in the array represents their visual order when displayed on the map, with objects in the beginning of the array located behind those at later indexes.

MKMapViewMBS.regionThatFits(region as MKCoordinateRegionMBS) as MKCoordinateRegionMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Adjusts the aspect ratio of the specified region to ensure that it fits in the map view’s frame.

region: The initial region whose span you want to adjust.

Returns a region that is still centered on the same point of the map but whose span values are adjusted to fit in the map view’s frame.

You can use this method to normalize the region values before displaying them in the map. This method returns a new region that both contains the specified region and fits neatly inside the map view’s frame.

MKMapViewMBS.removeAnnotation(annotation as MKAnnotationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Removes the specified annotation object from the map view.

annotation: The annotation object to remove. This object must conform to the MKAnnotationMBS interface.

If the annotation is currently associated with an annotation view, and that view has a reuse identifier, this method removes the annotation view and queues it internally for later reuse. You can retrieve queued annotation views (and associate them with new annotations) using the dequeueReusableAnnotationViewWithIdentifier method.

Removing an annotation object disassociates it from the map view entirely, preventing it from being displayed on the map. Thus, you would typically call this method only when you want to hide or delete a given annotation.

MKMapViewMBS.removeAnnotations(annotations() as MKAnnotationMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Removes an array of annotation objects from the map view.

annotations: The array of annotations to remove. Objects in the array must conform to the MKAnnotationMBS interface.

If any annotation object in the array has an associated annotation view, and if that view has a reuse identifier, this method removes the annotation view and queues it internally for later reuse. You can retrieve queued annotation views (and associate them with new annotations) using the dequeueReusableAnnotationViewWithIdentifier method.

Removing annotation objects disassociates them from the map view entirely, preventing them from being displayed on the map. Thus, you would typically call this method only when you want to hide or delete the specified annotations.

Some examples using this method:

MKMapViewMBS.removeOverlay(overlay as MKOverlayMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Removes a single overlay object from the map.

overlay: The overlay object to remove.

This method removes the overlay regardless of the level that it is in. Removing an overlay also removes its corresponding renderer, if one is in use. If the specified overlay is not currently associated with the map view, this method does nothing.

Some examples using this method:

MKMapViewMBS.removeOverlays(overlays() as MKOverlayMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 14.1 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Removes one or more overlay objects from the map.

overlays: An array of objects, each of which conforms to the MKOverlayMBS interface.

This method removes the specified overlays regardless of which level each one is in. Removing an overlay also removes its corresponding renderer, if one is in use. If a given overlay object is not associated with the map view, it is ignored.

MKMapViewMBS.rendererForOverlay(overlay as MKOverlayMBS) as MKOverlayRendererMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Returns the renderer object used to draw the contents of the specified overlay object.

overlay: The overlay object whose renderer you want.

Returns the renderer object in use for the specified overlay or nil if the overlay is not onscreen.

This method returns the renderer object that your control provided in its xrendererForOverlay event.

MKMapViewMBS.viewForAnnotation(annotation as MKAnnotationMBS) as MKAnnotationViewMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MapKit MBS MacFrameworks Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes Desktop & iOS
Returns the annotation view associated with the specified annotation object, if any.
Example
Function viewForAnnotation(mapView as MKMapViewMBS, annotation as MKAnnotationMBS) Handles viewForAnnotation as MKAnnotationViewMBS
// return nil for default annotation view

// new annotation view
Var v As New MKAnnotationViewMBS(annotation)

// get a picture and use it as decoration
Var pic As Picture = LogoMBS(100)
Var img As New NSImageMBS(pic)
img.setSize(pic.Width/2, pic.Height/2) // half size gives 2x resolution, if the picture isn't retina aware

// set image and return
v.image = img

Return v
End Function

annotation: The annotation object whose view you want.

Returns the annotation view or nil if the view has not yet been created. This method may also return nil if the annotation is not in the visible map region and therefore does not have an associated annotation view.

The items on this page are in the following plugins: MBS MacFrameworks Plugin.


The biggest plugin in space...