• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Use Search Results From Google Places API To Update Marker Location Or Create Marker

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This was originally posted on Stack Overflow: http://stackoverflow.com/questions/22308219/use-search-results-from-google-places-api-to-update-marker-location-or-create-ma
The post says I created it yesterday, but I am certain I created it the day before. I have yet to get a response. Please, while I appreciate not being spoon fed the answer right off the bat, try, also, not to speak in riddle. Thanks!

In my app I am using an if/else statement that, onMapLongClick, will update the location of the marker, if one exists, or create a marker if one does not exist. I wanted to use SearchView with Google Places API, so I utilized a tutorial I found reading through posts on Stack Overflow. It utilizes search results from Google Places API to create a marker. Nice! However, it is using its own addMarker. So, I am hoping someone would be so kind as to get me going in the right direction so that I am able to tie the results being generated from Google Places API in with my method for adding a marker. (Teach the man to fish, not give the man a fish.)

My method:

Tutorial method for Google-Places-API results:
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not clear on what the problem is. What happens at runtime? Which of this code is or is not being run, and how does that differ from your expectation of what would happen? Also, what does "it is using its own addMarker" mean?
 
Jared Snyder
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:I'm not clear on what the problem is. What happens at runtime? Which of this code is or is not being run, and how does that differ from your expectation of what would happen? Also, what does "it is using its own addMarker" mean?



The code runs 100% fine. However, I want the method I wrote for adding a marker to be the only method for adding a marker. So, instead of the selected search result being added to the map via the addMarker in the tutorial code, I want it to be added via my method- the one I have coded for the map. Does that make sense?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What prevents you from changing the code to use your method instead? Although I'm guessing that somewhere in it it in turn calls the standard addMarker method.
 
Jared Snyder
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having a hard time understanding how to replace the existing addMarker with my own. I figure I need to grab the LatLng from the selected location in the search results and then pass that to my marker method.
 
Jared Snyder
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, I tinkered and tinkered, and ended up just recycling my own method code into that of the search results. I am not sure if there is an easier way, but this is what I used.

reply
    Bookmark Topic Watch Topic
  • New Topic