Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[iOS] Compass does not receive touch events if its frame changes #3099

Closed
mappy-mobile opened this issue Nov 23, 2015 · 17 comments
Closed

[iOS] Compass does not receive touch events if its frame changes #3099

mappy-mobile opened this issue Nov 23, 2015 · 17 comments
Assignees
Labels
bug iOS Mapbox Maps SDK for iOS

Comments

@mappy-mobile
Copy link

If the user of the iOS framework changes the frame of the compass view (e.g. if part of the map is covered by UI elements) , the end user cannot tap on the compass to reset the north position.
The touch zone is still the default compass view position.

expected : update touch zone when changing compass view frame.

@tobrun
Copy link
Member

tobrun commented Nov 23, 2015

@mappy-mobile
is this issue related to Android or iOS?
In case of Android, how are you setting the location of the CompassView?
By using mMapView.setCompassMargins(int left, int top, int right, int bottom)?

@mappy-mobile
Copy link
Author

@tobrun oh sorry I forgot to specify it's related to the iOS lib. I'm adding a label.

edit: I can't, would you do it please ?

@mappy-mobile mappy-mobile changed the title Compass does not receive touch events if its frame changes [iOS] Compass does not receive touch events if its frame changes Nov 23, 2015
@friedbunny friedbunny added iOS Mapbox Maps SDK for iOS bug labels Nov 23, 2015
@1ec5
Copy link
Contributor

1ec5 commented Nov 23, 2015

I don’t see anything that explicitly favors the compass tap gesture recognizer over the single tap gesture recognizer. On top of that, the compass tap recognizer should be attached to the compass view, not its container. An argument in favor of #1830 perhaps.

@incanus
Copy link
Contributor

incanus commented Nov 23, 2015

We saw problems with this before related to a) constraints updating properly and b) taps on container vs. compass image as @1ec5 states. Also possibly related to clipping settings for the container view.

@1ec5
Copy link
Contributor

1ec5 commented Nov 23, 2015

It’s unlikely to be an issue with the constraints updating, though, because (unless I’m missing something) the compass still appears in the right place.

@mappy-mobile
Copy link
Author

Yes I'm using explicit values to change the frame of the compass view, my point was only about tap events registered in the wrong bounds.

@1ec5
Copy link
Contributor

1ec5 commented Nov 24, 2015

OK, that explains it. MGLMapView intercepts tap events on the compass view's invisible container view with a gesture recognizer. I think #1830 is the way to go here; we just need to make the button trigger the action on touch down rather than touch up inside.

@RomainQuidet
Copy link
Contributor

Hi,
Romain, from Mappy team, dedicated to mapbox SDK. I wonder why is there a container here for the compass ? It's a bit overkill for the memory. The compass view can itself handle the tap recognizer. And when not visible, the interaction can also be turned off with userInteractionEnabled property of the compass UIImageView.

What happened here is that the container is constrained by layout constraints. Our developer moved the compassView itself by modifying its frame. So yes, the container did not move, as the tap recognizer. And the compassView moved away.

If a view is constrained by layout constraints, modifying its frame is forbidden. One idea might be to add an API entry to set the compassView center position in the SDK.

Romain

@incanus
Copy link
Contributor

incanus commented Nov 24, 2015

The reason the compass has a container is due to jitter and performance with constraints directly against it, holding to the right and the top layout guide, while rotating. We hit this problem back in the raster SDK days (as well as this tap issue) and having a container solved this. See mapbox/DEPRECATED-mapbox-ios-sdk#315 for backstory.

@RomainQuidet
Copy link
Contributor

Hi,
It seems that the bug is not corrected... we set the compassView frame to something else, the touch is not working.
If a view is positioned by layout constraints, modifying its frame is forbidden, and result in unknown behavior. This is what happen here.
We need have have the possibility to change the compass position (as well as logo position). Adding an external API (ex: setOffset) will allow internal code to update the constraints and update the view. Another solution would be to expose the constraints but it is less user friendly.

I can take care of that in a pull request if you want.

@AdamBCo
Copy link

AdamBCo commented Dec 4, 2015

Any progress on this issue?

@RomainQuidet were you able to fix this issue?

@1ec5
Copy link
Contributor

1ec5 commented Dec 4, 2015

This was fixed in #3099, which is in 3.0.0.

@1ec5
Copy link
Contributor

1ec5 commented Dec 4, 2015

Oh never mind, I missed @RomainQuidet's comment above.

@1ec5 1ec5 reopened this Dec 4, 2015
@RomainQuidet
Copy link
Contributor

Hi,
Sorry no I did not work on that as @1ec5 was on it. I can work on it right now if needed.

@1ec5 1ec5 closed this as completed in 8ba6f80 Dec 7, 2015
@johndpope
Copy link

incidentally - for people coming here looking how to reposition compass -
in swift mapview - you can use
var rect = self.compassView.frame
rect.origin.y += self.frame.height - 110
self.compassView.frame = rect

@RomainQuidet
Copy link
Contributor

there's another story for that, it's #3697 with PR #4219

@haashem
Copy link

haashem commented Dec 25, 2016

I still have problem with compassView doesn't intercept touch event by changing its position

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

9 participants