How to move marker

65 views
Skip to first unread message

babar...@gmail.com

unread,
Apr 7, 2014, 1:51:39 AM4/7/14
to nutit...@googlegroups.com
Hello i have added marker to the map with the help of MarkerLayer. Can any body please tell how to move marker when location changes i.e how can i get the Marker object back that i have added to the markerlayer so i can set the new position.

Regards
Muhammad Babar

Marco Pleines

unread,
Apr 7, 2014, 7:38:44 AM4/7/14
to nutit...@googlegroups.com, babar...@gmail.com
This is a snippet that I used to draw a marker to the gps location.

Implement the Interface OrientationManager.OnChangedListener
Aetup the marker in the onCreate function and then update it on OnLocationChanged.

The variable currPosition is the Marker that I initialized within onCreate.


@Override
    public void onLocationChanged(OrientationManager orientationManager) {
        Location location = orientationManager.getLocation();
        MapPos mapPos = mapView.getLayers().getBaseProjection().fromWgs84(location.getLongitude(), location.getLatitude());
        // update the mapView focus
        mapView.setFocusPoint(mapPos);
       
        // update the position of the user's location marker
        currPosition.setMapPos(mapPos);

Jaak Laineste (Nutiteq)

unread,
Apr 7, 2014, 8:43:40 AM4/7/14
to nutit...@googlegroups.com
Hello,

with current API you cannot query from Layer. You have to remember the Marker object reference in application, and use it. So use class member instead of local variable. Then you can later call setMapPos() of it and it will be moved around.

Jaak


--
You received this message because you are subscribed to the Google Groups "Nutiteq-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nutiteq-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages