本文整理汇总了Java中com.amap.api.maps.model.Marker类的典型用法代码示例。如果您正苦于以下问题:Java Marker类的具体用法?Java Marker怎么用?Java Marker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Marker类属于com.amap.api.maps.model包,在下文中一共展示了Marker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initMap
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
private void initMap(){
if (aMap == null) {
aMap = mMapView.getMap();
}
UiSettings uiSettings=aMap.getUiSettings();
uiSettings.setZoomPosition(AMapOptions.ZOOM_POSITION_RIGHT_CENTER);
aMap.setOnMarkerClickListener(new AMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
int index = (int)marker.getObject();
viewPager.setCurrentItem(index);
return false;
}
});
}
示例2: addClusterToMap
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
/**
* 将聚合元素添加至地图上
*/
private void addClusterToMap(List<Cluster> clusters) {
ArrayList<Marker> removeMarkers = new ArrayList<>();
removeMarkers.addAll(mAddMarkers);
AlphaAnimation alphaAnimation=new AlphaAnimation(1, 0);
MyAnimationListener myAnimationListener=new MyAnimationListener(removeMarkers);
for (Marker marker : removeMarkers) {
marker.setAnimation(alphaAnimation);
marker.setAnimationListener(myAnimationListener);
marker.startAnimation();
}
for (Cluster cluster : clusters) {
addSingleClusterToMap(cluster);
}
}
示例3: onDestroy
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
/**
* 在不适用此Overlay功能时,以及onDestroy的生命周期里,调用此方法,回收相关资源,避免内存泄漏
*/
public void onDestroy() {
for (RankEntity rankEntity : mRankEntities) {
Marker marker = rankEntity.getMarker();
if (marker != null) {
marker.remove();
marker.destroy();
}
}
mRankEntities.clear();
mBitmapCache.evictAll();
}
示例4: onCreateView
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_map, container, false);
initview(savedInstanceState,view);
//beta版测试数据
LatLng latLng = new LatLng(39.906901,116.397972);
final Marker marker = aMap.addMarker(new MarkerOptions().position(latLng).title("苹果痂").snippet("苹果黑星菌"));
LatLng latLng0 = new LatLng(30.87394024,121.33850098);
final Marker marker0 = aMap.addMarker(new MarkerOptions().position(latLng0).title("樱桃白粉病").snippet("叉丝单囊壳菌"));
LatLng latLng1 = new LatLng(22.79643932,113.34594727);
final Marker marker1 = aMap.addMarker(new MarkerOptions().position(latLng1).title("玉米灰斑病").snippet("尖孢科孢子虫"));
LatLng latLng2 = new LatLng(22.54300097,114.12322998);
final Marker marker2 = aMap.addMarker(new MarkerOptions().position(latLng2).title("葡萄黑腐病").snippet("葡萄球座菌"));
LatLng latLng3 = new LatLng(30.35391637,104.38110352);
final Marker marker3 = aMap.addMarker(new MarkerOptions().position(latLng3).title("甜椒菌斑").snippet("野油菜黃單孢菌"));
LatLng latLng4 = new LatLng(25.35391637,109.38110352);
final Marker marker4 = aMap.addMarker(new MarkerOptions().position(latLng4).title("甜椒菌斑").snippet("野油菜黃單孢菌"));
return view;
}
示例5: addFeature
import com.amap.api.maps.model.Marker; //导入依赖的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);
}
}
}
示例6: getInfoWindowView
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
private View getInfoWindowView(Marker marker) {
if (infoWindowLayout == null) {
infoWindowLayout = new LinearLayout(MainActivity.this);
infoWindowLayout.setOrientation(LinearLayout.VERTICAL);
title = new TextView(MainActivity.this);
snippet = new TextView(MainActivity.this);
title.setTextColor(Color.BLACK);
snippet.setTextColor(Color.BLACK);
infoWindowLayout.setBackgroundResource(R.drawable.infowindow_bg);
infoWindowLayout.addView(title);
infoWindowLayout.addView(snippet);
}
return infoWindowLayout;
}
示例7: getInfoWindow
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
@Override
public View getInfoWindow(final Marker marker) {
View view = getLayoutInflater().inflate(R.layout.poikeywordsearch_uri,
null);
TextView title = (TextView) view.findViewById(R.id.title);
title.setText(marker.getTitle());
TextView snippet = (TextView) view.findViewById(R.id.snippet);
snippet.setText(marker.getSnippet());
ImageButton button = (ImageButton) view
.findViewById(R.id.start_amap_app);
// 调起高德地图app导航功能
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startAMapNavi(marker);
}
});
return view;
}
示例8: startAMapNavi
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
/**
* 调起高德地图导航功能,如果没安装高德地图,会进入异常,可以在异常中处理,调起高德地图app的下载页面
*/
public void startAMapNavi(Marker marker) {
//构造导航参数
NaviPara naviPara=new NaviPara();
//设置终点位置
naviPara.setTargetPoint(marker.getPosition());
//设置导航策略,这里是避免拥堵
naviPara.setNaviStyle(NaviPara.DRIVING_AVOID_CONGESTION);
try {
//调起高德地图导航
AMapUtils.openAMapNavi(naviPara, getApplicationContext());
} catch (com.amap.api.maps.AMapException e) {
//如果没安装会进入异常,调起下载页面
AMapUtils.getLatestAMapApp(getApplicationContext());
}
}
示例9: onInfoWindowClick
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
@Override
public void onInfoWindowClick(Marker marker) {
isClickStart = false;
isClickTarget = false;
if (marker.equals(startMk)) {
startTextView.setText("地图上的起点");
startPoint = AMapUtil.convertToLatLonPoint(startMk.getPosition());
startMk.hideInfoWindow();
startMk.remove();
} else if (marker.equals(targetMk)) {
endTextView.setText("地图上的终点");
endPoint = AMapUtil.convertToLatLonPoint(targetMk.getPosition());
targetMk.hideInfoWindow();
targetMk.remove();
}
}
示例10: rePlayTrace
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
/**
* 轨迹回放方法
*/
private TraceRePlay rePlayTrace(List<LatLng> list, final Marker updateMarker) {
TraceRePlay replay = new TraceRePlay(list, 100,
new TraceRePlayListener() {
@Override
public void onTraceUpdating(LatLng latLng) {
if (updateMarker != null) {
updateMarker.setPosition(latLng); // 更新小人实现轨迹回放
}
}
@Override
public void onTraceUpdateFinish() {
mDisplaybtn.setChecked(false);
mDisplaybtn.setClickable(true);
}
});
mThreadPool.execute(replay);
return replay;
}
示例11: drawMarkers
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
/**
* 绘制系统默认的1种marker背景图片
*/
public void drawMarkers() {
Marker marker = aMap.addMarker(new MarkerOptions()
.position(
new LatLng(responseMessage.body.getPositionLatitude(),
responseMessage.body.getPositionLongitude()))
.title("好好学习")
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
.perspective(true).draggable(true));
marker.setRotateAngle(0);// 设置marker旋转90度
marker.showInfoWindow();// 设置默认显示一个infowinfow
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(responseMessage.body.getPositionLatitude(),
responseMessage.body.getPositionLongitude()), 15));
}
示例12: drawMarkers
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
/**
* 绘制系统默认的1种marker背景图片
*/
public void drawMarkers() {
Marker marker = aMap.addMarker(new MarkerOptions()
.position(
new LatLng(mUrgentMessage.body.getPositionLatitude(),
mUrgentMessage.body.getPositionLongitude()))
.title("好好学习")
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
.perspective(true).draggable(true));
marker.setRotateAngle(0);// 设置marker旋转90度
marker.showInfoWindow();// 设置默认显示一个infowinfow
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(mUrgentMessage.body.getPositionLatitude(),
mUrgentMessage.body.getPositionLongitude()), 15));
}
示例13: drawMarkers
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
private void drawMarkers() {
AMap map = mapRef.get();
if (map != null && currentClusters != null) {
currentMarkers = new ArrayList<Marker>(currentClusters.size());
currentClusterPointsByMarker = new HashMap<Marker, ClusterPoint>(currentClusters.size());
MarkerOptionsChooser moc = options.getMarkerOptionsChooser();
for (ClusterPoint clusterPoint : currentClusters) {
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(clusterPoint.getMapPosition());
if (moc != null) {
moc.choose(markerOptions, clusterPoint);
}
Marker marker = map.addMarker(markerOptions);
currentMarkers.add(marker);
currentClusterPointsByMarker.put(marker, clusterPoint);
}
}
}
示例14: render
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
/**
* 自定义infowinfow窗口
*/
public void render(Marker marker, View view) {
String title = marker.getTitle();
TextView titleUi = ((TextView) view.findViewById(R.id.title));
if (title != null) {
SpannableString titleText = new SpannableString(title);
titleText.setSpan(new ForegroundColorSpan(Color.BLACK), 0,
titleText.length(), 0);
titleUi.setTextSize(13);
titleUi.setText(titleText);
} else {
titleUi.setText("");
}
String snippet = marker.getSnippet();
TextView snippetUi = ((TextView) view.findViewById(R.id.snippet));
if (snippet != null) {
SpannableString snippetText = new SpannableString(snippet);
snippetText.setSpan(new ForegroundColorSpan(Color.BLACK), 0,
snippetText.length(), 0);
snippetUi.setTextSize(10);
snippetUi.setText(snippetText);
} else {
snippetUi.setText("");
}
}
示例15: onMarkerClick
import com.amap.api.maps.model.Marker; //导入依赖的package包/类
@Override
public boolean onMarkerClick(Marker marker) {
if (marker.isInfoWindowShown()) {
marker.hideInfoWindow();
} else {
marker.showInfoWindow();
}
if (marker.equals(mWHU1)) {
endPoint = AMapUtil.convertToLatLonPoint(mWHU1.getPosition());
} else if (marker.equals(mWHU2)) {
endPoint = AMapUtil.convertToLatLonPoint(mWHU2.getPosition());
} else if (marker.equals(mWHU3)) {
endPoint = AMapUtil.convertToLatLonPoint(mWHU3.getPosition());
} else if (marker.equals(mWHU4)) {
endPoint = AMapUtil.convertToLatLonPoint(mWHU4.getPosition());
} else if (marker.equals(mWHU5)) {
endPoint = AMapUtil.convertToLatLonPoint(mWHU5.getPosition());
} else if (marker.equals(mWHU6)) {
endPoint = AMapUtil.convertToLatLonPoint(mWHU6.getPosition());
} else if (marker.equals(mWHU6)) {
endPoint = AMapUtil.convertToLatLonPoint(mWHU7.getPosition());
}
return false;
}