What have I learned… Day#180


Today is the first day that I have to curry out a project on my own. This project is about location-based system retrieving user current location and find targeted car parks nearby.

select “Google maps Activity”

First thing first, All I have to do is just create android new project with google map activity and
.
.
. BOOM!!! DONE
Now you have an android application with google map V2 build-in.

STEP 2 : getting Google Map API key.

you will see an url that directly lead you to key-generated page.
when you get API key, replace it between <string> tag.

STEP 3 : It’s time to get dirty.

when android studio generate an application successfully. you will see method called initializeMap() in onCreate() and onResume(), just leave it there.

this is the way to add a marker to your map.
custom your marker by using this lines of codes

title = set title to a “infoWindow”
snippet = set description to a “infoWindow”
icon = you have various choices to customize a marker

One thing that i have to mention you about is when you pick a marker, 2 icons gonna popup in the right bottom corner of the screen. These 2 icons will navigate you to the “real” google map application.

— How to zoom to your current location when launch the app —

According to this answer : http://stackoverflow.com/a/20930874/3011340
you can easily get current location and when you get the location replace it into newCameraPosition() method

There are several methods you should know :
-setMyLocationEnabled(boolean)
-getUiSettings().setRotateGesturesEnabled(boolean)
-setTrafficEnabled(boolean)

— How to add click event in infoWindow —

add infoWindow listener and check from its title

TODO: for tomorrow
- replace fragment after click infoWindow
- add application drawer
- (maybe) add viewpager …. just maybe

Reference:
- Android Hive
Vogella