01.
package
com.myapp;
02.
03.
import
com.google.android.gms.maps.GoogleMap;
04.
import
com.google.android.gms.maps.SupportMapFragment;
05.
import
com.google.android.gms.maps.model.LatLng;
06.
import
com.google.android.gms.maps.model.MarkerOptions;
07.
08.
import
android.os.Bundle;
09.
import
android.support.v4.app.FragmentActivity;
10.
11.
import
com.google.android.gms.maps.CameraUpdateFactory;
12.
13.
public
class
MainActivity
extends
FragmentActivity {
14.
15.
16.
private
GoogleMap googleMap;
17.
18.
19.
private
Double Latitude =
0.00
;
20.
private
Double Longitude =
0.00
;
21.
22.
protected
void
onCreate(Bundle savedInstanceState) {
23.
super
.onCreate(savedInstanceState);
24.
setContentView(R.layout.activity_main);
25.
26.
Latitude =
13.844205
;
27.
Longitude =
100.598856
;
28.
29.
if
(Latitude >
0
&& Longitude >
0
)
30.
{
31.
32.
googleMap = ((SupportMapFragment)getSupportFragmentManager()
33.
.findFragmentById(R.id.googleMap)).getMap();
34.
35.
36.
LatLng coordinate =
new
LatLng(Latitude, Longitude);
37.
googleMap.setMapType(com.google.android.gms.maps.GoogleMap.MAP_TYPE_HYBRID);
38.
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(coordinate,
17
));
39.
40.
41.
String toolTip = String.format(
"Your Location Lat=%s, Lon=%s"
, Latitude,Longitude);
42.
MarkerOptions marker =
new
MarkerOptions().position(
new
LatLng(Latitude, Longitude)).title(toolTip);
43.
googleMap.addMarker(marker);
44.
45.
}
46.
47.
}
48.
49.
}