3

Problem:

I am looking to suppress touch to the user location in efforts to block the "My Location" annotation


I have been looking for a solution for a while now and after extensive online research I have yet to find this question even posted.

I have created a mobile application written in Swift where there are notes on the MKMap View. The issue I am running into is when a user selects a note that they are near, It sometimes displays this "My location" annotation as apposed to displaying the correct note.

Im sure there is way to block this annotation and I have written a statement that helps me identify the pop-up

        if (((view.annotation?.title)!)! == "My Location"){
            print("wrong annotation selected")

Is there any way to disable touch to the user location icon?

I have already changed the color of the circle using

map.tintColor = UIColor(red:0.19, green:0.69, blue:0.73, alpha:1.0)

So I was thinking there might be like a

map.UserLocationTouch = false 

or something along those lines.

Looking to remove this pop-out

Kevin Maldjian
  • 147
  • 1
  • 10
  • Implement the viewForAnnotation delegate method and then you can return your own annotation view for the user location annotation – Paulw11 Nov 29 '17 at 20:54
  • 1
    Or you can simply hide the user location by setting the showsUserLocation property to false – Paulw11 Nov 29 '17 at 21:02
  • @Paulw11 I would like to keep the user location, it is needed because some notes cannot be opened if you are far away from them. – Kevin Maldjian Nov 29 '17 at 21:27
  • Is the note an annotation? Why is the callout from the user location a problem? – Paulw11 Nov 29 '17 at 21:36
  • The note usually opens up a new window with the information inside. Users need to be within 30 meters to open the note so they usually have to be on top of the image. If they are too close they will accidentally tap their current location which blocks the new window opening and displays the picture above. – Kevin Maldjian Nov 29 '17 at 21:42
  • See https://stackoverflow.com/questions/1145238/how-to-define-the-order-of-overlapping-mkannotationviews for some approaches to reordering the annotation views so that your note is on top. – Paulw11 Nov 29 '17 at 21:49

2 Answers2

6

mapView.userLocation.title = ""

And the annotation will not appear when you press.

Nicolas
  • 530
  • 6
  • 9
0

Hey there is an updated easy solution on:

.Net for iOS (Xamarin.iOS)

NativeMap.UserLocation.Title = "";

Swift:

mapView.userLocation.title = "";

Regards ;)

G Clovs
  • 2,442
  • 3
  • 19
  • 24
  • Please don't post identical answers to multiple questions. Instead, tailor the answer to the question asked. If the questions are exact duplicates of each other, please vote/flag to close instead. – Yunnosch Aug 25 '20 at 19:30