How would I implement a feature in which a user must use two fingers to pan the map with react-native-maps? It appears they do not have gestureHandling as a feature. I don't necessarily need a full answer, just some ideas to point me in the right direction. I also don't see very comprehensive gesture library other than the basic onPress.
https://github.com/react-community/react-native-maps/blob/master/docs/mapview.md
I had the same issue that I wanted:
Disabling one-finger panning on map
Enabling two-finger panning/zooming on map
For that you you can use this configuration:
<MapboxGL.MapView
style={[styles.map, style]}
styleURL={styleURL}
logoEnabled={false}
attributionEnabled={false}
scrollEnabled={false} // <-- Disables one-finger panning
pitchEnabled={false} // <--- Enable two-finger zooming + panning
rotateEnabled={false}
>
// ....
</MapboxGL.MapView>
Note to make this work it is important how you interact with two-finger. For instance, if you put your two fingers horizontally and start moving up/down (without any pitching) it starts changing the map perspective, instead of panning.
So make sure after putting your two fingers, you begins right away with a bit of pitch (=zooming) and then moving around your fingers make panning effect occurs.
Related
I am trying to replicate a view from a phone (using DeviceOrientationControls) to a desktop (using TrackballControls). I am passing the view state (camera position & direction) through an intermediary server, and have that part mostly working.
I'm having trouble setting the camera rotation on the desktop. The cameras are sync'd to look at the same point, but the view on the desktop (receiving the view state from the phone) rotates around the view angle.
I definitely don't fully understand quaternions or rotation order. I've tried applying those, but clearly I'm out of my element. I guess I'm just looking for some hints on how to sync the camera rotation on the desktop.
Looks like I had a (trackball) controls.update() in my animate() that was blowing away the rotation that I was setting. Camera position and direction are not changed by this, but the rotation (or the "roll" of the camera) was.
In TrackballControls, it would be nice to have a setting for programmatically updating the camera's rotation that wouldn't get squashed by a call to rotateCamera(). I'll have to think about that, because it doesnt seem like it would be easy to implement.
Pan works fine for me, but pinch with recognizer code like this does not:
- (void)pinchDetected:(UIPinchGestureRecognizer *)pinchRecognizer
{
CGFloat scale = pinchRecognizer.scale;
self.imageView.transform = CGAffineTransformScale(self.imageView.transform, scale, scale);
pinchRecognizer.scale = 1.0;
}
What happens is that the image view is continuously resetting the image according to its "mode", whether it's center, aspect fit, etc.
I solved my problem: I'm making my first image viewer, and to learn how to pinch and zoom, I naively googled for how to support gestures, which are not enabled by simply adding an image view to a view controller.
Unfortunately, there are many "tutorials" on this, showing how to program with the gesture recognizers, etc. And I spent a few hours going down this route unnecessarily. I kept going because I felt tantalizingly close to getting things working: The pan gesture was flawless and was "just" zoom that was broken.
(Side question: is there some awesome source for current, iOS 6 "best practices"?)
It turns out, this is the wrong path and needlessly complex for basic gesture recognition. All that's needed is to place the image view in a scroll view. 99% of the programming is taken care of. (I was convinced this had to be the case — I couldn't believe that such core functionality wouldn't be provided by cocoa touch.)
I am thinking to develop some tools for my prototype system. I saw a function in the following link and seems very useful for me as well. But I dont know how to implement it? any idea?
http://www.arcgis.com/home/item.html?id=9c0e319bfaff4d33a0fe2da97c2c3fd7
Thanks!!!
This may not be the most efficient solution, but you could create two viewports, both rendering the scene from the same camera, but before you render the viewport for the right-side half, set the visible flag of walls (and other Mesh objects as necessary) to false, and after rendering the right-side scene reset those flags to true. This wouldn't implement the slider, however.
I've found a gorgeous switch that I'd like to implement in iOS. The artist (#jasonlong) has kindly shared his PSD of the components at 365psd.com, along with a crafty little javascript as a demo.
Now, here's where I get into trouble... The custom UISlider and UISwitch examples I've found seem to rely on a track that's stationary with a movable knob/toggle. In the switch below, it would require a knob/track to animate behind a mask that also passes through touch events.
I've never been much of an interface coder, but this cute little bugger is just to awesome to leave alone. Can someone point me in the right direction?
I suggest just having the background stationary, and just fade between them? Sliding the track is probably not going to work so well, as you can still see the green/white around the edge of the knob.
I'm trying to recreate the behaviour of the photos app, where you can pan, pinch and rotate simultaneously. I have the basics working, but I'm stuck on something.
For the pan, I offset the centrepoint of the view by the translation amount. This is working well.
For the pinch and rotate I'm applying an affine transform to the view. This is also working well.
The problem is when I pan (ie. move the subview), and then pinch or rotate - the affine transform seems to get applied using the old centre point of the view. I though that it should use the current centre point as the transform origin - as I'm updating the centrepoint when I pan I though that this should work. Instead of a rotation about the centrepoint of the subview, I get a rotational movement about the original centrepoint.
How do I correct this ? It's clearly possible to combine these three gestures intuitively, as the photos app does it successfully.
I tried using an affine translation for the pan, but the effect was the same.
Apple have confirmed this appears to be a bug with the way that gesture recognisers are working in iPhone OS 3.2. I have filed a bug report.