yandex / mapkit-android-demo

MapKit Android demo
Other
122 stars 61 forks source link

Android Yandex Mapkit set dynamic gps for markers #114

Closed ersenkaya closed 5 years ago

ersenkaya commented 5 years ago

I have 2 question which have same answer.

1- We have a device which has no gps, we are getting gps information from another device in vehicle and we need to monitoring device location on map. How can we do it, is there any easy way like place mark object?

Now we are using placemark to show on map while map fragment creating, but we can not set gps position to marker, do we need remove and again and again?

Do you have another solution to make sth like this?

2- If I want to create android mobile application to track vehicles which I get gps infromation from server side with socket or api?

Thank you.

vbazhenov commented 5 years ago

but we can not set gps position to marker, do we need remove and again and again?

Have you tried setGeometry method? https://tech.yandex.com/maps/mapkit/doc/3.x/concepts/android/mapkit/ref/com/yandex/mapkit/map/PlacemarkMapObject-docpage/#method_detail__method_setGeometry___NonNullPoint

ersenkaya commented 5 years ago

but we can not set gps position to marker, do we need remove and again and again?

Have you tried setGeometry method? https://tech.yandex.com/maps/mapkit/doc/3.x/concepts/android/mapkit/ref/com/yandex/mapkit/map/PlacemarkMapObject-docpage/#method_detail__method_setGeometry___NonNullPoint

Thank you for your answer, yes I tried it. Do you have sample code block to understand how to use?

eberkovich commented 5 years ago

There is map object example https://github.com/yandex/mapkit-android-demo/blob/b506c53b72455802c1c7661e422d25d5cf663538/src/main/java/com/yandex/mapkitdemo/MapObjectsActivity.java

It shows how to add map objects. If you want to change position, you just need to call PlacemarkMapObject.setGeometry(latitude, longitude) method. Please keep in mind, the first argument is latitude.