com.amap.api.maps.model.Marker Java Examples
The following examples show how to use
com.amap.api.maps.model.Marker.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RouteOverlay.java From BmapLite with Apache License 2.0 | 6 votes |
/** * 去掉BusRouteOverlay上所有的Marker。 * @since V2.1.0 */ public void removeFromMap() { if (startMarker != null) { startMarker.remove(); } if (endMarker != null) { endMarker.remove(); } for (Marker marker : stationMarkers) { marker.remove(); } for (Polyline line : allPolyLines) { line.remove(); } destroyBit(); }
Example #2
Source File: AmapFragment.java From BmapLite with Apache License 2.0 | 6 votes |
public void clearRangingPoi() { clearMarker(); for (Marker marker : mRangingMarkerList) { marker.remove(); } mRangingMarkerList.clear(); for (Polyline polyline : mLineList) { polyline.remove(); } mLineList.clear(); mPoiList.clear(); mTotal = 0; }
Example #3
Source File: PoiClickActivity.java From TraceByAmap with MIT License | 6 votes |
/** * Marker 点击回调 * @param marker * @return */ @Override public boolean onMarkerClick(Marker marker) { // 构造导航参数 NaviPara naviPara = new NaviPara(); // 设置终点位置 naviPara.setTargetPoint(marker.getPosition()); // 设置导航策略,这里是避免拥堵 naviPara.setNaviStyle(AMapUtils.DRIVING_AVOID_CONGESTION); try { // 调起高德地图导航 AMapUtils.openAMapNavi(naviPara, getApplicationContext()); } catch (com.amap.api.maps.AMapException e) { // 如果没安装会进入异常,调起下载页面 AMapUtils.getLatestAMapApp(getApplicationContext()); } mAMap.clear(); return false; }
Example #4
Source File: AmapFragment.java From BmapLite with GNU General Public License v3.0 | 6 votes |
public void getFavoriteList() { if (null != mFavMarkerList && !mFavMarkerList.isEmpty()) { for (Marker o : mFavMarkerList) { o.remove(); } mFavMarkerList.clear(); } if (null != mFavoriteInteracter) { List<MyPoiModel> favoriteList = mFavoriteInteracter.getFavoriteList(); if (null != favoriteList && !favoriteList.isEmpty()) { for (MyPoiModel poi : favoriteList) { BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.ic_grade_point_2); Marker marker = mAmap.addMarker(new MarkerOptions().position(new LatLng(poi.getLatitude(), poi.getLongitude())).title(poi.getName()).snippet("").anchor(0.5f, 0.5f).icon(bitmapDescriptor)); mFavMarkerList.add(marker); } } } }
Example #5
Source File: GaoDeMapAiLineManager.java From FimiX8-RE with MIT License | 6 votes |
private void deleteMarker(boolean isMapPoint, LatLng homeLocation) { if (!isMapPoint) { if (this.mMarkerList.size() != 0) { this.mSelectMarker = (Marker) this.mMarkerList.get(this.mMarkerList.size() - 1); } else { return; } } if (this.mSelectMarker == null) { return; } if (((MapPointLatLng) this.mSelectMarker.getObject()).isIntertestPoint) { removeInterestPoint(); } else { removeLinePoint(homeLocation); } }
Example #6
Source File: RecordShowActivity.java From RecordPath3D with Apache License 2.0 | 6 votes |
/** * 轨迹回放方法 */ 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; }
Example #7
Source File: PoiKeywordSearchActivity.java From TraceByAmap with MIT License | 6 votes |
/** * 调起高德地图导航功能,如果没安装高德地图,会进入异常,可以在异常中处理,调起高德地图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()); } }
Example #8
Source File: GaoDeMapAiLineManager.java From FimiX8-RE with MIT License | 6 votes |
public void drawPointLine(LatLng latLngDevice) { this.latLngs.clear(); if (this.polyline != null) { this.polyline.remove(); } this.latLngs.add(latLngDevice); for (Marker marker : this.mMarkerList) { this.latLngs.add(marker.getPosition()); } PolylineOptions polylineOptions = new PolylineOptions(); polylineOptions.addAll(this.latLngs); polylineOptions.setDottedLine(true); polylineOptions.color(this.context.getResources().getColor(R.color.x8_drone_inface_line)).zIndex(50.0f); polylineOptions.width(10.0f); this.polyline = this.aMap.addPolyline(polylineOptions); }
Example #9
Source File: AmapFragment.java From BmapLite with GNU General Public License v3.0 | 6 votes |
public void clearRangingPoi() { clearMarker(); for (Marker marker : mRangingMarkerList) { marker.remove(); } mRangingMarkerList.clear(); for (Polyline polyline : mLineList) { polyline.remove(); } mLineList.clear(); mPoiList.clear(); mTotal = 0; }
Example #10
Source File: AMapViewManager.java From react-native-amap with MIT License | 6 votes |
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); } } }
Example #11
Source File: GaoDeMapAiLineManager.java From FimiX8-RE with MIT License | 6 votes |
public void setAiLineMarkByHistory(List<X8AiLinePointLatlngInfo> points, int mapTpye) { for (X8AiLinePointLatlngInfo point : points) { int res; MapPointLatLng mp = new MapPointLatLng(); if (point.getYawMode() == 0) { res = R.drawable.x8_ai_line_point_no_angle1; } else { res = R.drawable.x8_ai_line_point_with_angle1; } BitmapDescriptor mBitmapDescriptor = new GaoDeMapCustomMarkerView().createCustomMarkerView2(this.context, res, this.mMarkerList.size() + 1); mp.altitude = (float) point.getAltitude(); mp.nPos = this.mMarkerList.size() + 1; LatLng latLng = new LatLng(point.getLatitude(), point.getLongitude()); Marker mMarker = this.aMap.addMarker(new MarkerOptions().position(latLng).icon(mBitmapDescriptor).anchor(0.5f, 0.5f).draggable(false)); mp.longitude = latLng.longitude; mp.latitude = latLng.latitude; mMarker.setObject(mp); this.mMarkerList.add(mMarker); mp.distance = 0.0f; this.mMapPointList.add(mp); setRotateAngle(mMarker, point.getYaw() / 100.0f); } if (points.size() > 0) { drawPointLine(this.mGaodeMapLocationManager.getHomeLocation()); } }
Example #12
Source File: PoiOverlay.java From TraceByAmap with MIT License | 5 votes |
/** * 添加Marker到地图中。 * @since V2.1.0 */ public void addToMap() { try{ for (int i = 0; i < mPois.size(); i++) { Marker marker = mAMap.addMarker(getMarkerOptions(i)); marker.setObject(i); mPoiMarks.add(marker); } }catch(Throwable e){ e.printStackTrace(); } }
Example #13
Source File: CustomMarkerActivity.java From TraceByAmap with MIT License | 5 votes |
/** * marker 必须有设置图标,否则无效果 * * @param marker */ private void dropInto(final Marker marker) { final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); final LatLng markerLatlng = marker.getPosition(); Projection proj = aMap.getProjection(); Point markerPoint = proj.toScreenLocation(markerLatlng); Point startPoint = new Point(markerPoint.x, 0);// 从marker的屏幕上方下落 final LatLng startLatLng = proj.fromScreenLocation(startPoint); final long duration = 800;// 动画总时长 final Interpolator interpolator = new AccelerateInterpolator(); handler.post(new Runnable() { @Override public void run() { long elapsed = SystemClock.uptimeMillis() - start; float t = interpolator.getInterpolation((float) elapsed / duration); double lng = t * markerLatlng.longitude + (1 - t) * startLatLng.longitude; double lat = t * markerLatlng.latitude + (1 - t) * startLatLng.latitude; marker.setPosition(new LatLng(lat, lng)); if (t < 1.0) { handler.postDelayed(this, 16); } } }); }
Example #14
Source File: CustomMarkerActivity.java From TraceByAmap with MIT License | 5 votes |
/** * marker点击时跳动一下 */ public void jumpPoint(final Marker marker) { final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); Projection proj = aMap.getProjection(); Point startPoint = proj.toScreenLocation(Constants.XIAN); startPoint.offset(0, -100); final LatLng startLatLng = proj.fromScreenLocation(startPoint); final long duration = 1500; final Interpolator interpolator = new BounceInterpolator(); handler.post(new Runnable() { @Override public void run() { long elapsed = SystemClock.uptimeMillis() - start; float t = interpolator.getInterpolation((float) elapsed / duration); double lng = t * Constants.XIAN.longitude + (1 - t) * startLatLng.longitude; double lat = t * Constants.XIAN.latitude + (1 - t) * startLatLng.latitude; marker.setPosition(new LatLng(lat, lng)); if (t < 1.0) { handler.postDelayed(this, 16); } } }); }
Example #15
Source File: AmapFragment.java From BmapLite with GNU General Public License v3.0 | 5 votes |
@Override public boolean onMarkerClick(Marker marker) { if (mIsModeRanging) { MyPoiModel poi = new MyPoiModel(TypeMap.TYPE_AMAP); poi.setLatitude(marker.getPosition().latitude); poi.setLongitude(marker.getPosition().longitude); mPoiList.add(poi); makeRangingMarker(poi); setRangingPolyLine(); } else { int distance = 0; if (null != BApp.MY_LOCATION) { distance = (int) AMapUtils.calculateLineDistance(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude()), marker.getPosition()); } if (null == clickMapPoiNow) { clickMapPoiNow = new MyPoiModel(TypeMap.TYPE_AMAP); } if (null != marker.getTitle() && !marker.getTitle().isEmpty()) { clickMapPoiNow.setTypeMap(TypeMap.TYPE_AMAP); clickMapPoiNow.setName(marker.getTitle()); clickMapPoiNow.setLongitude(marker.getPosition().longitude); clickMapPoiNow.setLatitude(marker.getPosition().latitude); mAmap.animateCamera(CameraUpdateFactory.changeLatLng(new LatLng(clickMapPoiNow.getLatitude(), clickMapPoiNow.getLongitude()))); ((MainActivity) getActivity()).showPoiLay(clickMapPoiNow, distance); } else { ((MainActivity) getActivity()).showPoiLay(BApp.MY_LOCATION, distance); } } return true; }
Example #16
Source File: MarkerClickActivity.java From TraceByAmap with MIT License | 5 votes |
/** * 对marker标注点点击响应事件 */ @Override public boolean onMarkerClick(final Marker marker) { if (aMap != null) { jumpPoint(marker); } Toast.makeText(MarkerClickActivity.this, "您点击了Marker", Toast.LENGTH_LONG).show(); return true; }
Example #17
Source File: ParticleWeatherMapActivity.java From TraceByAmap with MIT License | 5 votes |
/** * 获取是哪里需要显示天气 * * @param position * @return */ private String getShowWeatherPositio(CameraPosition position) { if(position == null) { return null; } List<Marker> markers = aMap.getMapScreenMarkers(); // 去除离屏幕最近的marker Marker needShowMarker = null; float distance = 0; for (Marker marker : markers) { LatLng markerPos = marker.getPosition(); float curDistanct = AMapUtils.calculateLineDistance(markerPos, position.target); if(distance == 0) { distance = curDistanct; needShowMarker = marker; } else { if(curDistanct < distance) { needShowMarker = marker; } } } if(needShowMarker != null && needShowMarker.getObject() != null) { return (String) needShowMarker.getObject(); } return null; }
Example #18
Source File: PoiAroundSearchActivity.java From TraceByAmap with MIT License | 5 votes |
/** * 添加Marker到地图中。 * @since V2.1.0 */ public void addToMap() { if(mPois != null) { int size = mPois.size(); for (int i = 0; i < size; i++) { Marker marker = mamap.addMarker(getMarkerOptions(i)); PoiItem item = mPois.get(i); marker.setObject(item); mPoiMarks.add(marker); } } }
Example #19
Source File: GaoDeMapAiLineManager.java From FimiX8-RE with MIT License | 5 votes |
private void clearPointMark() { for (Marker marker : this.mMarkerList) { marker.remove(); } for (Marker marker2 : this.interestMarkerList) { marker2.remove(); } clearMarker(); }
Example #20
Source File: AmapFragment.java From BmapLite with Apache License 2.0 | 5 votes |
@Override public boolean onMarkerClick(Marker marker) { if (mIsModeRanging) { MyPoiModel poi = new MyPoiModel(TypeMap.TYPE_AMAP); poi.setLatitude(marker.getPosition().latitude); poi.setLongitude(marker.getPosition().longitude); mPoiList.add(poi); makeRangingMarker(poi); setRangingPolyLine(); } else { int distance = 0; if (null != BApp.MY_LOCATION) { distance = (int) AMapUtils.calculateLineDistance(new LatLng(BApp.MY_LOCATION.getLatitude(), BApp.MY_LOCATION.getLongitude()), marker.getPosition()); } if (null == clickMapPoiNow) { clickMapPoiNow = new MyPoiModel(TypeMap.TYPE_AMAP); } if (null != marker.getTitle() && !marker.getTitle().isEmpty()) { clickMapPoiNow.setTypeMap(TypeMap.TYPE_AMAP); clickMapPoiNow.setName(marker.getTitle()); clickMapPoiNow.setLongitude(marker.getPosition().longitude); clickMapPoiNow.setLatitude(marker.getPosition().latitude); mAmap.animateCamera(CameraUpdateFactory.changeLatLng(new LatLng(clickMapPoiNow.getLatitude(), clickMapPoiNow.getLongitude()))); ((MainActivity) getActivity()).showPoiLay(clickMapPoiNow, distance); } else { ((MainActivity) getActivity()).showPoiLay(BApp.MY_LOCATION, distance); } } return true; }
Example #21
Source File: PoiOverlay.java From BmapLite with Apache License 2.0 | 5 votes |
/** * 添加Marker到地图中。 * @since V2.1.0 */ public void addToMap() { try{ for (int i = 0; i < mPois.size(); i++) { Marker marker = mAMap.addMarker(getMarkerOptions(i)); marker.setObject(i); mPoiMarks.add(marker); } }catch(Throwable e){ e.printStackTrace(); } }
Example #22
Source File: GeoFence_Nearby_Activity.java From Android_Location_Demo with Apache License 2.0 | 5 votes |
private void removeMarkers() { if(null != centerMarker){ centerMarker.remove(); centerMarker = null; } if (null != markerList && markerList.size() > 0) { for (Marker marker : markerList) { marker.remove(); } markerList.clear(); } }
Example #23
Source File: RouteOverlay.java From BmapLite with Apache License 2.0 | 5 votes |
protected void addStationMarker(MarkerOptions options) { if(options == null) { return; } Marker marker = mAMap.addMarker(options); if(marker != null) { stationMarkers.add(marker); } }
Example #24
Source File: ParticleWeatherMapActivity.java From TraceByAmap with MIT License | 5 votes |
/** * 初始化添加marker */ private void initWeather() { CameraPosition cameraPosition = aMap.getCameraPosition(); boolean isNeedShowWeatherMarker = false; if (cameraPosition != null) { isNeedShowWeatherMarker = cameraPosition.zoom <= MAX_SHOW_WEATHER_MARKER_ZOOM; // 查看首次需不需要显示粒子效果 changeParticleOverlayState(cameraPosition); } for (int i = 0; i < latLngs.length; i++) { LatLng latLng = latLngs[i]; int index = i % pngPaths.length; // 天气状态随机选取,如果要使用到实际场景,这里需要修改成真是数据 String path = pngPaths[index]; BitmapDescriptor bitmapDescriptor = bitmapDescriptorHashtable.get(path); if (bitmapDescriptor == null) { bitmapDescriptor = BitmapDescriptorFactory.fromAsset(path); bitmapDescriptorHashtable.put(path, bitmapDescriptor); } Marker marker = aMap.addMarker(new MarkerOptions().position(latLng).icon(bitmapDescriptor).visible(isNeedShowWeatherMarker)); if (marker != null) { marker.setObject(path); markerList.add(marker); } } }
Example #25
Source File: RouteOverlay.java From BmapLite with GNU General Public License v3.0 | 5 votes |
protected void addStationMarker(MarkerOptions options) { if(options == null) { return; } Marker marker = mAMap.addMarker(options); if(marker != null) { stationMarkers.add(marker); } }
Example #26
Source File: AMapMarkerManager.java From react-native-amap with MIT License | 5 votes |
@Override public void receiveCommand(AMapMarker view, int commandId, @Nullable ReadableArray args) { switch (commandId) { case SHOW_INFO_WINDOW: ((Marker) view.getFeature()).showInfoWindow(); break; case HIDE_INFO_WINDOW: ((Marker) view.getFeature()).hideInfoWindow(); break; } }
Example #27
Source File: PlaceMapFragment.java From Fishing with GNU General Public License v3.0 | 5 votes |
@Override public boolean onMarkerClick(Marker marker) { if (marker.equals(mMyLocation))return false; if (lastMarker != null) lastMarker.setIcon(BitmapDescriptorFactory .fromResource(mMarkerMap.get(lastMarker).getCostType() == 0 ? R.drawable.location_point_green : R.drawable.location_point_red)); moveTo(marker.getPosition().latitude, marker.getPosition().longitude); marker.setIcon(BitmapDescriptorFactory .fromResource(mMarkerMap.get(marker).getCostType() == 0 ? R.drawable.location_point_bigger_green : R.drawable.location_point_bigger_red)); lastMarker = marker; return false; }
Example #28
Source File: GeoFence_Multiple_Activity.java From Android_Location_Demo with Apache License 2.0 | 5 votes |
private void removeMarkers() { if(null != centerMarker){ centerMarker.remove(); centerMarker = null; } if (null != markerList && markerList.size() > 0) { for (Marker marker : markerList) { marker.remove(); } markerList.clear(); } }
Example #29
Source File: RoutePOIActivity.java From TraceByAmap with MIT License | 5 votes |
/** * 添加Marker到地图中。 * @since V2.1.0 */ public void addToMap() { for (int i = 0; i < mPois.size(); i++) { Marker marker = mamap.addMarker(getMarkerOptions(i)); RoutePOIItem item = mPois.get(i); marker.setObject(item); mPoiMarks.add(marker); } }
Example #30
Source File: RoutePOIActivity.java From TraceByAmap with MIT License | 5 votes |
/** * 从marker中得到poi在list的位置。 * * @param marker 一个标记的对象。 * @return 返回该marker对应的poi在list的位置。 * @since V2.1.0 */ public int getPoiIndex(Marker marker) { for (int i = 0; i < mPoiMarks.size(); i++) { if (mPoiMarks.get(i).equals(marker)) { return i; } } return -1; }