Android 지도 테스트

Programming/Android 2014. 3. 1. 13:10 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.


super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);


LocationManager locationManager;

GoogleMap googleMap = ((SupportMapFragment) getSupportFragmentManager()

.findFragmentById(R.id.map)).getMap();

locationManager = (LocationManager) this

.getSystemService(Context.LOCATION_SERVICE);


Criteria criteria = new Criteria();

criteria.setAccuracy(Criteria.ACCURACY_COARSE);

criteria.setAltitudeRequired(false);

criteria.setBearingRequired(false);

criteria.setSpeedRequired(false);


String provider = locationManager.getBestProvider(criteria, true);// "gps";

Location location = locationManager.getLastKnownLocation(provider);


double[] result = new double[] {

location.getLatitude(), location.getLongitude()

};

LatLng myPosition = new LatLng(result[0], result[1]);

googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(myPosition, 15));



Marker myMarker = googleMap

.addMarker(new MarkerOptions()

.position(new LatLng(result[0], result[1]))

.title("MyPosition")

.icon(BitmapDescriptorFactory

.fromResource(R.drawable.ic_launcher)));



'Programming > Android' 카테고리의 다른 글

Android APK 추출 툴  (0) 2014.03.07
Android 화면 크기 읽기, dpi, inch, cm  (0) 2014.03.02
Android 2014-03-01 GoogleMap V2 띄우기  (0) 2014.03.01
Android 반짝이는 화면  (0) 2014.02.22
Android GoogleMap API V2  (0) 2014.01.19