在Android API级别23中获取当前位置 [英] Getting current Location in Android API level 23
本文介绍了在Android API级别23中获取当前位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public void onMapReady(GoogleMap googleMap){
mMap = googleMap;
mMap.setMyLocationEnabled(true);
位置location = null;
LatLng currentPosition = new LatLng(location.getLatitude(),location.getLongitude());
mMap.addMarker(new MarkerOptions()。position(currentPosition).title(Current Location));
这是正确的@Abhishek
解决方案
你可以这样使用
@Override
public void onMapReady map){
// TODO自动生成的方法stub
map.setMyLocationEnabled(true);
LatLng currentPosition = new LatLng(location.getLatitude(),location.getLongitude());
map.addMarker(new MarkerOptions()。position(currentPosition).title(Current Location));
}
位置
从 onLocationChanged
方法
@Override
public void onLocationChanged位置loc){
// TODO自动生成的方法stub
location = new LatLng(loc.getLatitude(),loc.getLongitude());
----------
}
Hello i am completely new in android location concept, i have created one map activity in android studio. this is the code.
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.setMyLocationEnabled(true);
Location location = null;
LatLng currentPosition = new LatLng(location.getLatitude(), location.getLongitude());
mMap.addMarker(new MarkerOptions().position(currentPosition).title("Current Location"));
Is this is correct @Abhishek
解决方案
You can use like this
@Override
public void onMapReady(GoogleMap map) {
// TODO Auto-generated method stub
map.setMyLocationEnabled(true);
LatLng currentPosition = new LatLng(location.getLatitude(),location.getLongitude());
map.addMarker(new MarkerOptions().position(currentPosition).title("Current Location"));
}
location
which get from onLocationChanged
method
@Override
public void onLocationChanged(Location loc) {
// TODO Auto-generated method stub
location = new LatLng(loc.getLatitude(), loc.getLongitude());
----------
}
这篇关于在Android API级别23中获取当前位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文