Android Question How to create a gmap polyline to smooth the line and how to implement StartForeground ?

Discussion in 'Android Questions' started by Sapta, Mar 24, 2018.

  1. Sapta

    Sapta Member Licensed User

    Hi all,
    I created a program to track when running. The obstacles I found,

    1. How to write in the gmap so that it is smooth? because this time the result is like this (the lines are stiff, especially at the turn). I use this code, is there anything missing ?

    pl = GMap.AddPolyline
    l1.Initialize(LatitudeStart, LongitudeStart)
    l2.Initialize(LatitudeReal, LongitudeReal)
    If SettingWhiteMap = True Then
    End If
    pl.points = Points

    It wants to be like this


    Thank you
    Last edited: Mar 25, 2018
  2. Erel

    Erel Administrator Staff Member Licensed User

    Please create a new thread for each question.
  3. BillMeyer

    BillMeyer Active Member Licensed User

    Question 1:

    With Google Maps "Snap To Road" API you can "smooth" your track provided you stay on a road. You can read more here

    You require a Key from Google.

    Here is some code, lifted from B4J - but should serve as a guide to doing it in B4A.

    Dim StR As String
    Dim LatLng(16As String

    '            StR = "path="&LatLng(1)&","&LatLng(8)&"|"&LatLng(2)&","&LatLng(9)&"&interpolate=True&key=AIzaSyC324Thq0DI1l_xPmyQP7LYU3n1rkEOkxI"
                StR = "path="&LatLng(1)&","&LatLng(8)&"|"&LatLng(2)&","&LatLng(9)&"|"&LatLng(3)&","&LatLng(10)&"|"&LatLng(4)&","&LatLng(11)&"|"&LatLng(5)&","&LatLng(12)&"|"&LatLng(6)&","&LatLng(13)&"|"&LatLng(7)&","&LatLng(14)&"&interpolate=True&key=Your Key Here"

    Log("Post String: "&CRLF&StR)

    Dim j1 As HttpJob
    "", Me)

    Wait For (j1) JobDone(j2 As HttpJob)
    If j2.Success Then
    End If
    The other questions, as @Erel says, separate threads helps to keep them from getting lost in other threads and someone who has done this previously will spot it and answer for you.

    Enjoy your day
  4. Sapta

    Sapta Member Licensed User

    Ok @Erel , I've revised this question into sections. Thank you

    Hi @BillMeyer
    What if it is not on the road? because it could run in the fields, parks or other places. I've updated the sample image like the example I want.

    But I am grateful for your answer because it has increased my knowledge. Thank you. :)
  5. BillMeyer

    BillMeyer Active Member Licensed User


    Sorry, my knowledge ends at the edge of the road.
    Sapta likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice