rotate the map at a point other than the center MapPos

48 views
Skip to first unread message

smo...@gmail.com

unread,
Apr 12, 2017, 4:41:24 AM4/12/17
to Nutiteq-dev
Hi,

anyone can help me.

How to rotate the map at a point other than the center MapPos?!

I know there are two methods, setMapRotation() and rotate(), but they don't act as I expect. They rotate in the center point and then move to the defined point.

thank you.

mte...@cartodb.com

unread,
Apr 12, 2017, 9:09:29 AM4/12/17
to Nutiteq-dev
Hello,

the methods you mention have two versions - ones without pivot and ones with explicitly defined pivot. The ones with pivot point (or target position) should do exactly that - rotate around the specified pivot point. A brief testing shows that they seem to work fine (I used CartoMobileSDK 4.0.1). Can you provide a sample or more detailed description of the issue?

Thanks,
Mark

Mojtaba Pirayesh

unread,
Apr 18, 2017, 2:11:40 AM4/18/17
to Nutiteq-dev
Hello,

I want to develop navigator with nutiteq SDK v3.0.x,

I am currently moving the marker and map by animation with handler in android .


handler.post(new Runnable() {
    @Override
    public void run() {
            long elapsed = SystemClock.uptimeMillis() - start;
            float t = interpolator.getInterpolation((float) elapsed
                    / duration);

            double mx = t * target.getX() + (1 - t)
                    * markerLocation.getX();
            double my = t * target.getY() + (1 - t)
                    * markerLocation.getY();
            MapPos markerPosition = new MapPos(mx, my);
            marker.setPos(markerPosition);

            if (isFollow) {
                double xr = t * x + (1 - t)
                        * posCenter.getX();
                double yr = t * y + (1 - t)
                        * posCenter.getY();
                getMap().setFocusPos(new MapPos(xr, yr), 0);
            }
        if (t < 1.0) {
            handler.postDelayed(this, 12);
        }



The problem occurs whenever i want to rotate map around the marker pivot point with duration.
In other words i want to move and rotate map together simultaneously around the current marker pivot position (at the same time marker is moving with animation).

Is there any prepared method to do so?

Thanks for attention

mte...@cartodb.com

unread,
Apr 19, 2017, 8:01:30 AM4/19/17
to Nutiteq-dev
Hi,

do I understand correctly - the issue you are facing is that map focus point and marker position are not synchronized and sometimes marker 'jumps around' a bit?

If this is the case, then you can do synchronous update by using custom MapRendererListener class. You must implement onBeforeDrawFrame method where you do actual map update (thus set both focus point and marker position). You must attach your custom MapRendererListener instance to MapRenderer instance, that you can get from MapView instance using getMapRenderer() method.

Hope this helps,
Mark

mte...@cartodb.com

unread,
Apr 19, 2017, 8:05:13 AM4/19/17
to Nutiteq-dev
A quick comment - the solution I described assumes that you are using Carto Mobile SDK, not Nutiteq SDK 3.x. The solution for Nutiteq SDK is similar, though the details differ. I strongly suggest using Carto Mobile SDK, as Nutiteq SDK 3.x is in maintenance mode for commercial customers, while Carto Mobile SDK is in active development and contains many improvements and fixes.

Regards,
Mark
Reply all
Reply to author
Forward
0 new messages