public class MapInitFragment extends MapFragment implements AMapLocationListener {
**********
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_map_init, container, false);
mMapView = view.findViewById(R.id.map);
//在activity执行onCreate时执mMapView.onCreate(savedInstanceState),创建地图
mMapView.onCreate(savedInstanceState);
// 此方法须覆写,虚拟机需要在很多情况下保存地图绘制的当前状态。
if(aMap == null)
aMap = mMapView.getMap();
init(aMap);
return view;
}
protected void locate(AMap aMap, MyLocationStyle myLocationStyle)
{
myLocationStyle.interval(1); //设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。
myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);
aMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style
aMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。
}
init最后调用的就是locate方法,在这里我尝试了很多次都无法定位,而其他功能都可以实现
https://lbs.amap.com/api/andr...
这是相关api介绍
我尝试了很多次,就是没法找到定位蓝点,查看logcat也没有什么头绪