Pergunta

Good morning folks,

I'm using the Nutiteq SDK to render offline maps of openstreet maps and to use offline routing as well.

As soon as the device gets a gps signal, the map's center point is moved to the location which is returned by the orientation and location manager. The activtiy, that I'm talking about, has a onLocationChanged() method which is always called when the location of the user is changed.

So far so good, at this point I'm trying to implement a function which is pretty similar to to google maps. If the user moves the map by gesture some parts of the onLocationChanged() method get disabled. So that the map center point is not updated anymore because the user wants to have a look somewhere else on the map. After pressing a buttong, just like in google, the routing continous.

My problem is that I can't define gestures like this in my concerning activty like this: http://mrbool.com/how-to-work-with-swipe-gestures-in-android/28088

After talking to the guys who developed Nutiteq SDK they told me to override the function onTouchEvent() in a new custom mapView class. Well, this kinda works, but I have to rewrite every single gesture, for example scrolling the map.

After all I just want to toggle a boolean false if the map is moved by a fling gesture or something similar.

Do you know any alternative which might could solve my problem?

Here is a link to Nutiteq's forum where I posted my problem earlier: https://groups.google.com/forum/#!topic/nutiteq-dev/x55SMOnsuk0

Foi útil?

Solução

I would try following:

a) create own mapview like following: https://gist.github.com/nutiteq/b546aaac8cdcfa6a7f09 . It just reuses normal touch handlers.

b) use MyMapView instead of MapView in layout xml and code.

c) in your LocationListener:

        @Override

        public void onLocationChanged(Location location) {

           if(!mapView.isTouched())

                 mapView.setFocusPoint(mapView.getLayers().getBaseProjection().fromWgs84(location.getLongitude(), location.getLatitude()));

        }

d) When you turn on "GPS follow" reset touch state with mapView.setTouched(false);

But it is possible I miss some case here. I know it can be tricky to get it right.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top