1. Are you ready for the Galaxy S20? Here is everything we know so far!

Implementing a LocationListerner and Display Google Map

Discussion in 'Android Development' started by ac4android, Feb 9, 2016.

  1. ac4android

    ac4android Well-Known Member
    Thread Starter

    Hi.

    I need to get the location of my pizza-delivery guy ( not Spiderman ) and end up with something like this :
    Code (Text):
    1.  
    2. LocationListener listener = new LocationListener()
    3. LocationManager locMgr = (LocationManager)getSystemService(Context.LOCTION_SERVICE);
    4. logMgr.requestLocationUpdates(LocatoinManager.GPS_PROVIDER, 10000, 1, listener);
    5.  
    I can also get the distance traveled. But what I need is the GPS location on the Google Map and there's where I am a bit lost. How do I display the Map with the location?

    Thanks in advance.
     



    1. Download the Forums for Android™ app!


      Download

       
  2. HeavensSentSword

    HeavensSentSword Well-Known Member

    Code (Java):
    1.  
    2. double lat, lon;
    3. Marker mymarker= map.addMarker(new MarkerOptions().position(new LatLng(lat, lon))
    4.       .title("Pizza Guy Location"));
    So you have his long and lat of the pizza guy? if you have the lat and long you could try something like this
     
    ac4android likes this.
  3. ac4android

    ac4android Well-Known Member
    Thread Starter

    Hi. I am seeking some hi-level advice on how to approach this.

    In simple terms, I'll accessing a transactional database on a server via web service and getting back a dataset of 120 records on average ( could be as many as 500 ) from which I will pull 6 to 7 into SQLite. The fragment will be using a Cursor via a SimpleCursorAdaper to display the list view which the user can scroll.

    ListView will have a click listener and onclick will call on the next fragment which displays the location of the pizza delivery guy on the city map.

    QUESTION: the transactional records on the server database get updated about once every 30 seconds (the pizza guy is really fast on his bike). Since HTTPS is stateless, I have to replace all the records on SQLite every 30 seconds too. Does that sound right? Is that the right approach? Do you see any potential pitfalls and "gotchas", before I nock myself out coding the impossible?

    I don't see how else I can update the values of the displayed records on the list view and the location on the map without refreshing the whole dataset for the cursor.

    Is this how you would approach it? What do you think?
     
  4. HeavensSentSword

    HeavensSentSword Well-Known Member

    Are you using the users geographical location as the filter to show which points are displayed?
     
  5. ac4android

    ac4android Well-Known Member
    Thread Starter

    No, not at this point. That's another app I have to create i.e. show the pizzeria within a radius of e.g. 2 kilometers of my location ( hence the listerner).

    I have a more urgent question on how to actually get the Google Map to display. I have created another thread for it.
    http://androidforums.com/threads/need-some-help-google-maps-activity.1004071/
     
Loading...
Similar Threads - Implementing LocationListerner Display
  1. wmw_hv
    Replies:
    0
    Views:
    217
  2. GST GridTech
    Replies:
    0
    Views:
    375
  3. Terryalexa8
    Replies:
    3
    Views:
    670
  4. tcerda
    Replies:
    0
    Views:
    1,166
  5. Kiran Shaw
    Replies:
    1
    Views:
    1,467
  6. Muhammad Raihan Hanif
    Replies:
    3
    Views:
    1,154
  7. jmmartins
    Replies:
    0
    Views:
    1,745
  8. Natann99
    Replies:
    0
    Views:
    2,970
  9. professor_of_stupidity
    Replies:
    0
    Views:
    2,065
  10. Kazafka
    Replies:
    3
    Views:
    1,399

Share This Page

Loading...