本文整理汇总了Java中com.amap.api.maps.MapView类的典型用法代码示例。如果您正苦于以下问题:Java MapView类的具体用法?Java MapView怎么用?Java MapView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapView类属于com.amap.api.maps包,在下文中一共展示了MapView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.amap.api.maps.MapView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test_basicmap_activity);
/*
* 设置离线地图存储目录,在下载离线地图或初始化地图设置;
* 使用过程中可自行设置, 若自行设置了离线地图存储的路径,
* 则需要在离线地图下载和使用地图页面都进行路径设置
* */
//Demo中为了其他界面可以使用下载的离线地图,使用默认位置存储,屏蔽了自定义设置
// MapsInitializer.sdcardDir =OffLineMapUtils.getSdCacheDir(this);
mapView = (MapView) findViewById(R.id.map);
mapView.onCreate(savedInstanceState);// 此方法必须重写
init();
}
示例2: onCreateView
import com.amap.api.maps.MapView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View sView = inflater.inflate(R.layout.fragment_map_simple, container, false);
mMapView = (MapView) sView.findViewById(R.id.map_simple);
mMapView.onCreate(savedInstanceState);
AMap map = mMapView.getMap();
map.setMapType(AMap.MAP_TYPE_NIGHT);
map.getUiSettings().setZoomControlsEnabled(false);
map.getUiSettings().setAllGesturesEnabled(false);
LatLng loc = new LatLng(39.9793157, 116.3107618);
CameraUpdate mCameraUpdate = CameraUpdateFactory.newCameraPosition(new CameraPosition(loc,14 ,0,0));
map.animateCamera(mCameraUpdate, 1000, null);
if(mCircleTask == null) {
mCircleTask = new CircleTask(map, loc, 15, 20, 40);
}
return sView;
}
示例3: AmapManager
import com.amap.api.maps.MapView; //导入依赖的package包/类
public AmapManager(Context conext, MapView mapView) {
this.mContext = conext;
dbManager = new MapDatebaseManager(conext);
if (aMap == null) {
aMap = mapView.getMap();
}
//设置线段属性
polylineOptions = new PolylineOptions().width(10).color(lineColor);
//设置锚点属性锚点
markerOptions = new MarkerOptions();
// 绑定 Marker 被点击事件
aMap.setOnMarkerClickListener(markerClickListener);
//绑定信息窗点击事件
aMap.setOnInfoWindowClickListener(infoWindowClicklistener);
}
示例4: onCreate
import com.amap.api.maps.MapView; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_location);
mapView = (MapView) findViewById(R.id.map_route);
mlist = (ListView) findViewById(R.id.location_listView);
ll_back= (LinearLayout) findViewById(R.id.location_layout_back);
ll_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
mlist.setOnItemClickListener(this);
mapView.onCreate(savedInstanceState);
if (aMap == null) {
aMap = mapView.getMap();
aMap.setOnCameraChangeListener(this);
setUpMap();
}
}
示例5: onCreate
import com.amap.api.maps.MapView; //导入依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_geofence_new);
setTitle(R.string.districtGeoFence);
// 初始化地理围栏
fenceClient = new GeoFenceClient(getApplicationContext());
lyOption = findViewById(R.id.ly_option);
btAddFence = (Button) findViewById(R.id.bt_addFence);
tvResult = (TextView) findViewById(R.id.tv_result);
tvResult.setVisibility(View.GONE);
etCustomId = (EditText) findViewById(R.id.et_customId);
etKeyword = (EditText) findViewById(R.id.et_keyword);
cbAlertIn = (CheckBox) findViewById(R.id.cb_alertIn);
cbAlertOut = (CheckBox) findViewById(R.id.cb_alertOut);
cbAldertStated = (CheckBox) findViewById(R.id.cb_alertStated);
mMapView = (MapView) findViewById(R.id.map);
mMapView.onCreate(savedInstanceState);
init();
}
示例6: onCreate
import com.amap.api.maps.MapView; //导入依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_geofence_new);
setTitle(R.string.roundGeoFence);
// 初始化地理围栏
fenceClient = new GeoFenceClient(getApplicationContext());
lyOption = findViewById(R.id.ly_option);
btAddFence = (Button) findViewById(R.id.bt_addFence);
btOption = (Button) findViewById(R.id.bt_option);
tvGuide = (TextView) findViewById(R.id.tv_guide);
tvResult = (TextView) findViewById(R.id.tv_result);
tvResult.setVisibility(View.GONE);
etCustomId = (EditText) findViewById(R.id.et_customId);
etRadius = (EditText) findViewById(R.id.et_radius);
cbAlertIn = (CheckBox) findViewById(R.id.cb_alertIn);
cbAlertOut = (CheckBox) findViewById(R.id.cb_alertOut);
cbAldertStated = (CheckBox) findViewById(R.id.cb_alertStated);
mMapView = (MapView) findViewById(R.id.map);
mMapView.onCreate(savedInstanceState);
markerOption = new MarkerOptions().draggable(true);
init();
}
示例7: onCreate
import com.amap.api.maps.MapView; //导入依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_geofence_new);
setTitle(R.string.polygonGeoFence);
// 初始化地理围栏
fenceClient = new GeoFenceClient(getApplicationContext());
btAddFence = (Button) findViewById(R.id.bt_addFence);
tvGuide = (TextView) findViewById(R.id.tv_guide);
tvResult = (TextView) findViewById(R.id.tv_result);
tvResult.setVisibility(View.GONE);
etCustomId = (EditText) findViewById(R.id.et_customId);
cbAlertIn = (CheckBox) findViewById(R.id.cb_alertIn);
cbAlertOut = (CheckBox) findViewById(R.id.cb_alertOut);
cbAldertStated = (CheckBox) findViewById(R.id.cb_alertStated);
mMapView = (MapView) findViewById(R.id.map);
mMapView.onCreate(savedInstanceState);
bitmap = BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW);
markerOption = new MarkerOptions().icon(bitmap).draggable(true);
init();
}
示例8: onCreate
import com.amap.api.maps.MapView; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "onCreate: ");
setContentView(R.layout.activity_voice_db_record_db);
mMapView = (MapView) findViewById(R.id.record_db_map_view);
mMapView.onCreate(savedInstanceState);// 此方法必须重写
AMap mAMap = mMapView.getMap();
mAMap.setLocationSource(this);// 设置定位监听
mAMap.setOnMapLoadedListener(this);
//mAMap.getUiSettings().setMyLocationButtonEnabled(true);// 设置默认定位按钮是否显示
mAMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
RecordDBFragment fragment = RecordDBFragment.newInstance();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.record_db_fl, fragment);
transaction.commit();
}
示例9: setRegion
import com.amap.api.maps.MapView; //导入依赖的package包/类
@ReactProp(name = "region")
public void setRegion(MapView mapView, @Nullable ReadableMap region) {
if (region == null) return;
AMap map = mapView.getMap();
Double lat = region.getDouble("latitude");
Double lng = region.getDouble("longitude");
Double lngDelta = region.getDouble("longitudeDelta");
Double latDelta = region.getDouble("latitudeDelta");
LatLngBounds bounds = new LatLngBounds(
new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
);
if (mapView.getHeight() <= 0 || mapView.getWidth() <= 0) {
map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lng), 10));
boundsToMove = bounds;
} else {
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
}
}
示例10: addFeature
import com.amap.api.maps.MapView; //导入依赖的package包/类
public void addFeature(MapView parent, View child, int index) {
AMap map = parent.getMap();
if (child instanceof AMapMarker) {
AMapMarker annotation = (AMapMarker) child;
annotation.addToMap(map);
features.add(index, annotation);
Marker marker = (Marker) annotation.getFeature();
markerMap.put(marker, annotation);
} else if (child instanceof AMapPolyline) {
AMapPolyline polylineView = (AMapPolyline) child;
polylineView.addToMap(map);
features.add(index, polylineView);
Polyline polyline = (Polyline) polylineView.getFeature();
polylineMap.put(polyline, polylineView);
} else {
ViewGroup children = (ViewGroup) child;
for (int i = 0; i < children.getChildCount(); i++) {
addFeature(parent, children.getChildAt(i), index);
}
}
}
示例11: updateExtraData
import com.amap.api.maps.MapView; //导入依赖的package包/类
@Override
public void updateExtraData(MapView view, Object extraData) {
// if boundsToMove is not null, we now have the MapView's width/height, so we can apply
// a proper camera move
if (boundsToMove != null) {
HashMap<String, Float> data = (HashMap<String, Float>) extraData;
float width = data.get("width");
float height = data.get("height");
view.getMap().moveCamera(
CameraUpdateFactory.newLatLngBounds(
boundsToMove,
(int) width,
(int) height,
0
)
);
boundsToMove = null;
}
}
示例12: onCreate
import com.amap.api.maps.MapView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shopmap_activity);
ManageActivityUtils.addActivity(this);
//如果安卓5.0设置状态栏为orange
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(getResources().getColor(R.color.orange));
}
//初始化各个控件ID
initID();
//先初始化mapview,是地图能正常显示出来
mapView = (MapView) this.findViewById(R.id.map);
mapView.onCreate(savedInstanceState);
//得到amap
aMap = mapView.getMap();
aMap.setLocationSource(this);// 设置定位监听
aMap.getUiSettings().setMyLocationButtonEnabled(true);// 设置默认定位按钮是否显示
aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
mUiSettings=aMap.getUiSettings();
mUiSettings.setZoomControlsEnabled(false);//隐藏放大按钮
}
示例13: onCreate
import com.amap.api.maps.MapView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.fab).setOnClickListener(this);
mPopupMenu = new PopupMenu(this, findViewById(R.id.fab));
mPopupMenu.getMenuInflater().inflate(R.menu.menu_main, mPopupMenu.getMenu());
mPopupMenu.setOnMenuItemClickListener(this);
mapView = (MapView) findViewById(R.id.map);
mapView.onCreate(savedInstanceState);// 必须要写
if (aMap == null) {
aMap = mapView.getMap();
setUpMap();
}
startLocationService();
mDownloadInfoBar = (LinearLayout) findViewById(R.id.downloadInfoBar);
mDownloadInfoBar.setVisibility(View.GONE);
}
示例14: onCreate
import com.amap.api.maps.MapView; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
//获取地图控件引用
mMapView = (MapView) findViewById(R.id.map);
//在activity执行onCreate时执行mMapView.onCreate(savedInstanceState),创建地图
mMapView.onCreate(savedInstanceState);
AMap aMap = mMapView.getMap();
aMap.setMapType(AMap.MAP_TYPE_NORMAL);
// 设置定位监听
aMap.setLocationSource(this);
// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
aMap.setMyLocationEnabled(true);
// 设置定位的类型为定位模式,有定位、跟随或地图根据面向方向旋转几种
aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
}
示例15: onCreate
import com.amap.api.maps.MapView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fence_trace);
// if (savedInstanceState == null) {
// getSupportFragmentManager().beginTransaction()
// .add(R.id.container, new MainActivity.PlaceholderFragment())
// .commit();
// }
mapView = (MapView) findViewById(R.id.trace_mapView);
mapView.onCreate(savedInstanceState);
mapView.getMap().setOnMapLoadedListener(this);
//初始化定位对象
mLocationManagerProxy = LocationManagerProxy.getInstance(this);
// 混合定位 定位时间间隔 定位距离间隔Gps 回调监听
//注册定位
mLocationManagerProxy.requestLocationData(LocationProviderProxy.AMapNetwork,2000, 15, this);
// LatLng latlng = new LatLng(0.0,0.0);
// list.add(latlng);
}