Detect tap on a label in Mapbox map on iOS - ios

I'd like to know if there is a way to best detect a users tap on a label?
The new iOS15 Maps app allows a tap on e.g. a cities name and then shows informations about that city.
I am now wondering if something similar can be done with mapbox?
I know that there is a mapView.visibleFeatures(in: myRect) function that can somehow help here. So I can convert my finger location to a rect and then get all features there.
BUT... my city e.g. might have a label that is let's say 200 px wide. So I would need to have a quite large rect to find the point of my city label. And then I will also get all kinds of other labels that might be there. Maybe even not visible, but in the dataset.
Is there no way to ask the map what the frontmost element was when I tapped? So that when I tap on the far end of the label, I still get that ONE feature?
I am still using Mapbox V6.3... the latest before their last major update.
But if it's not possible with that version, an answer about the latest V10.something would also be great.

For v10, this example demonstrates how to identify features near a click. While the overall example is to a different end, the onMapClick functions shows the method to find a feature and then build an annotation.
https://docs.mapbox.com/ios/maps/examples/view-annotation-marker/

Related

Apple Maps Location Marker like in Find Friends App

I have an app where I want the user to place a marker on a map and drag a circle to define a range around that notification, exactly as in Apple's Find Friends App (when you pick one of your friends and subscribe for notifications when he arrives or leaves a certain location).
Looks like this:
The marker can be dragged and moved like always, but the solid circle on the right side is used to define a range around the marker.
Does anyone have an idea on how to implement that? Maybe someone has already implemented something like this and wants to share his code :-).
Thanks.
Ok, I found some very useful sourcecode. Here it is, in case somebody else needs it as well: https://github.com/d0ping/DBMapSelectorViewController

how to let user drop interactive pin/marker on one uiimage

Right now I am working on one application which needs to have an interactive image.
While the user is viewing this image, they should be able to drop pin/marker onto the image by tap any location on the image. Once a pin/marker is dropped on the image, user should be able to tap the pin/marker again to add some comments to the pin, delete this pin/marker or even some other operation.
Right now, I am using the MKOverlayView to hold my image and put the MKOverlayView into a MKMapView so that I can use customized annotations to do that. However, there are always some zooming issues when I limited the visible region of the view(Because I do not need the entire world map). More importantly, I find out that I cannot get rid of the leftbuttom legal link(I need to submit my app to app store. And Apple does not allow it.) Also, each time when I first load the app, I can definitely see the mapping is loading and the map grid. And I do not want user to see it.
So I am thinking to find some other ways. Can anyone provide me a more feasible way to implement it, like some similar project example or tutorial? Any help is appreciated.
Thanks

Disable iOS "Perspective Compensation" programmatically?

Maybe I'm just searching for the wrong term, but I've been able to find very little information on this subject, and I think it could be a problem for my app.
A while back, there was an article on the accuracy of the touch screens on iOS devices, and it seemed quite poor compared to other phones. Here is a link a posting about it:
http://forums.macrumors.com/showthread.php?t=1660713
Anyway, many of the commenters referred to "perspective compensation" as a cause for the inaccuracy. Basically, they are saying that iOS intentionally registers touches above the actual point of contact to compensate for the typical viewing angle of the user or for the angle of their finger or something like that. I have found that there is some credibility to that claim myself by doing as one of the commenters suggested and trying to use my iPhone upside down. I did find that it was difficult to touch things in some cases, and I have also noticed this problem in one of the apps I'm developing.
So, in case you want to skip all that rambling above, here is why it's a problem for me:
I am developing an app that is intended to be used by two people at the same time. The iPhone or iPad is placed on a surface between two people who are sitting across from one another, and they are instructed to quickly and accurately touch items on their respective halves of the screen competitively. What the article's comments made me suspect might happen, and what I have also found in practice is that the person using the phone upside down will have trouble touching buttons and dots on their first try. I've also tested slowly with a stylus and found that the touchable area of a button does indeed extend below a button, or above the button for the person using the phone upside down, hence the discrepancy and problem/disadvantage for that person.
So finally, if you want to skip that also, here is my question: Can "perspective compensation"(if that's what it's called) be disabled programmatically, and can it be done for specific views of an app? Have any of you noticed this and dealt with it in an app of yours?
While I have found that "perspective compensation" does seem to be occurring, I have not found any official documentation of it, and therefore have no idea how or if it can be disabled. When I search for "perspective compensation," the only results I find are links to the same article and comments.
I can't help but expect that this may have been asked before or is solvable with a simple checkbox, but perhaps for lack of the correct term to use, I have been unable to find any leads.
Thanks in advance for any of your solutions or suggestions!
This can't be done with the current SDK. All we have access to is the touch location, which is at a single point. Other search terms you might try are "digitizer" or "raw touch data", but there is definitely no check box or simple option.
To implement this, you will have to compensate for the touch location yourself. You'll need to play around with a compensating offset value for the upside-down buttons. Hit testing on views is probably the best place to do this, then your buttons can just respond to events as normal.

"Custom Map Field" features

There does not seem to be a lot of information on the "Custom Map Field" features. I am adding Images to my custom MapField and would like to make those images clickable. If anyone is familiar with this please let me know and ill post my Code snippet , etc.
Thank you
There are two MapField classes in the API: the old net.rim.device.api.lbs.MapField, available since OS 4.5, and the newer net.rim.device.api.lbs.maps.ui.MapField, available from OS 6.0 onwards. For the newest one, the default action when an item is clicked is to show a dialog with info, but I think you could listen for clicks by setting a custom MapAction instance in the MapField. If not possible, then for both old and new mapfields you can override navigationClick and look for the nearest clickable item to the map center. This nearest neighbour lookup should be optimized in case you have a large number of clickable items (for instance, skipping all non visible elements). For touchscreen enabled devices, you can override touchEvent, retrieve the clicked position and do the same.
Actually both approaches are compatible.

How can I get a slot machine effect in the IOS SDK with text?

I need to create a list of words then have the words cycle through in a slot machine effect when swiped from top to bottom.
the only issues I'm having problems figuring out is the scrolling text part. UIPICKERVIEW doesn't cycle around (plus I need to only show one option at a time). I've hunted for examples and/or tutorials regarding this but haven't found anything that points me in the right direct.
Anyone know of a tutorial or have suggestions where I can get started or further my research? thanks.
You could use iCarousel for this:
https://github.com/nicklockwood/iCarousel
Run the Basic iOS Demo and select the Cylinder carousel type in vertical orientation with wrap on. If that looks like what you want, the documentation will explain how you can set it up in your project.

Resources