Java Code Examples for com.amap.api.maps.model.Marker#getPosition()

The following examples show how to use com.amap.api.maps.model.Marker#getPosition() . 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: MarkerClickActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * marker点击时跳动一下
 */
public void jumpPoint(final Marker marker) {
	final Handler handler = new Handler();
       final long start = SystemClock.uptimeMillis();
       Projection proj = aMap.getProjection();
       final LatLng markerLatlng = marker.getPosition();
       Point markerPoint = proj.toScreenLocation(markerLatlng);
       markerPoint.offset(0, -100);
       final LatLng startLatLng = proj.fromScreenLocation(markerPoint);
       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 * 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 2
Source File: CustomMarkerActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 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 3
Source File: CustomMarkerActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 监听拖动marker时事件回调
 */
@Override
public void onMarkerDrag(Marker marker) {
	String curDes = marker.getTitle() + "拖动时当前位置:(lat,lng)\n("
			+ marker.getPosition().latitude + ","
			+ marker.getPosition().longitude + ")";
	markerText.setText(curDes);
}
 
Example 4
Source File: ParticleWeatherMapActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 获取是哪里需要显示天气
 *
 * @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 5
Source File: PlaceLocationSelectActivity.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onMarkerClick(Marker marker) {
    if (marker.equals(mMyLocation)){
        if (mLastMarker != null) mLastMarker.destroy();
        mPoint = marker.getPosition();
        mGeocoderSearch.getFromLocationAsyn(new RegeocodeQuery(new LatLonPoint(marker.getPosition().latitude,marker.getPosition().longitude), 50,GeocodeSearch.AMAP));
    }
    return true;
}