How to allow users draw lines on google maps application

  • Replies:4
Green
  • Forum posts: 2

Nov 18, 2014, 3:25:53 AM via Website

Hi everybody, I was wondering on how to implement drawing polylines on google maps v2 by the user. After doing alot of googling I found this stackoverflow.com/questions/20901141/how-to-draw-free-hand-polygon-in-google-map-v2-in-android tutorial that claimed that I could achieve it by following the guidelines. But When I tried it implementing it, I got a blank google map fragment. Guys do think something is missing in this tutorial or I am the one not getting it right?

Reply
Kevin Berendsen
  • Forum posts: 118

Nov 18, 2014, 10:35:17 AM via Website

Could you paste your code using pastebin.com or similar? Do you get any message at the spot where the map fragment should be?

Reply
Green
  • Forum posts: 2

Nov 19, 2014, 5:01:55 AM via Website

here is the link to the code pastebin.com/1xgKiBdi

Reply
Kevin Berendsen
  • Forum posts: 118

Nov 19, 2014, 9:53:38 AM via App

What you try to accomplice could be done in much less code than you have now buddy. I will take a huge part of your code and remove the unnecessary. But first I will compile your code to see if you're missing any libraries or if you re using any outdated libraries. I will reply again with the outcome of this post within an hour. Im currently not at work yet.

Reply
Kevin Berendsen
  • Forum posts: 118

Nov 19, 2014, 11:01:34 AM via Website

Kevin Berendsen

What you try to accomplice could be done in much less code than you have now buddy. I will take a huge part of your code and remove the unnecessary. But first I will compile your code to see if you're missing any libraries or if you re using any outdated libraries. I will reply again with the outcome of this post within an hour. Im currently not at work yet.

Okay so I compiled your code and indeed it gave me a white map without the possibility to scroll. I remembered having a similar problem some weeks ago and found out that you didn't add a valid api key to your manifest. You require to add a valid api key in your androidmanifest.xml in order to let it work.

Example of an api key in the Google Developer Console: http://prntscr.com/57wbng

Google Maps API Tutorial to add a generated API key to your manifest and how to get a key: https://developers.google.com/maps/documentation/android/start#get_an_android_certificate_and_the_google_maps_api_key

This is how your app should look like after adding the API key. As you can see in my first screenshot above, I added a new allowed application to the list:

image

Green

Reply