Search in sources :

Example 1 with Marker

use of com.amap.api.maps.model.Marker in project YourEyes by SevenLJY.

the class MapActivity method showMarker.

/**
     * showMarker():在指定位置显示一个marker
     * 参数:latLng:要加marker的位置
     * marker暂时已指定
     * */
private void showMarker(LatLng latLng) {
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.smallplaceholder));
    markerOptions.draggable(true);
    //添加marker
    Marker marker = aMap.addMarker(markerOptions);
}
Also used : MarkerOptions(com.amap.api.maps.model.MarkerOptions) Marker(com.amap.api.maps.model.Marker)

Example 2 with Marker

use of com.amap.api.maps.model.Marker in project ride-read-android by Ride-Read.

the class MapFragment method addMomentMarker.

private void addMomentMarker(LatLng latLng, Bitmap bitmap, MapMoment moment) {
    if (null == latLng || null == bitmap)
        return;
    MarkerOptions markerOption = new MarkerOptions();
    markerOption.position(latLng);
    //设置Marker可拖动
    markerOption.draggable(false);
    markerOption.icon(BitmapDescriptorFactory.fromBitmap(bitmap));
    // 将Marker设置为贴地显示,可以双指下拉地图查看效果
    //设置marker平贴地图效果
    markerOption.setFlat(false);
    Marker marker = mAMap.addMarker(markerOption);
    marker.setObject(moment);
    TextOptions textOptions = new TextOptions().position(latLng).text(moment.getCount() + "").fontColor(Color.WHITE).backgroundColor(getResources().getColor(R.color.green_common)).fontSize(30).zIndex(1.f);
    mAMap.addText(textOptions);
}
Also used : MarkerOptions(com.amap.api.maps.model.MarkerOptions) Marker(com.amap.api.maps.model.Marker) TextOptions(com.amap.api.maps.model.TextOptions)

Example 3 with Marker

use of com.amap.api.maps.model.Marker in project ride-read-android by Ride-Read.

the class MapFragment method addSignInMarker.

private void addSignInMarker(LatLng latLng) {
    final Marker marker = addMarker(latLng);
    if (marker != null) {
        final long start = SystemClock.uptimeMillis();
        Projection proj = mAMap.getProjection();
        Point markerPoint = proj.toScreenLocation(latLng);
        markerPoint.offset(0, -500);
        final LatLng startLatLng = proj.fromScreenLocation(markerPoint);
        final long duration = 2000;
        final Interpolator interpolator = new BounceInterpolator();
        mHandler.post(new Runnable() {

            @Override
            public void run() {
                long elapsed = SystemClock.uptimeMillis() - start;
                float t = interpolator.getInterpolation((float) elapsed / duration);
                double lng = t * latLng.longitude + (1 - t) * startLatLng.longitude;
                double lat = t * latLng.latitude + (1 - t) * startLatLng.latitude;
                marker.setPosition(new LatLng(lat, lng));
                if (t < 1.0) {
                    mHandler.postDelayed(this, 16);
                }
            }
        });
    }
    mHandler.postDelayed(() -> {
        mSignInDialogFragment = SignInDialogFragment.newInstance(AMapLocationUtils.getLocDetail());
        mSignInDialogFragment.show(getFragmentManager(), "sign_in");
    }, 1000L);
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) Projection(com.amap.api.maps.Projection) BounceInterpolator(android.view.animation.BounceInterpolator) Interpolator(android.view.animation.Interpolator) Marker(com.amap.api.maps.model.Marker) LatLonPoint(com.amap.api.services.core.LatLonPoint) Point(android.graphics.Point) LatLng(com.amap.api.maps.model.LatLng)

Example 4 with Marker

use of com.amap.api.maps.model.Marker in project JustAndroid by chinaltz.

the class MapActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activitty_nearbypark);
    ButterKnife.bind(this);
    isFirstInitMap = true;
    mContext = this;
    navTitle.setText("地图相关导航");
    String[] titles = { "新街口", "夫子庙", "百家湖", "河西万达" };
    hotAreaList = new ArrayList();
    LatLng xinjiekouLatlng = new LatLng(32.0414637353, 118.7851165312);
    LatLng fuzimiaoLatlng = new LatLng(32.0206226446, 118.7889921341);
    LatLng baijiahuLatlng = new LatLng(31.9319650736, 118.8212252856);
    LatLng hexiLatlng = new LatLng(32.0328683928, 118.7360117294);
    hotAreaList.add(xinjiekouLatlng);
    hotAreaList.add(fuzimiaoLatlng);
    hotAreaList.add(baijiahuLatlng);
    hotAreaList.add(hexiLatlng);
    hListViewAdapter = new HorizontalListViewAdapter(getApplicationContext(), titles);
    horizontalListView.setAdapter(hListViewAdapter);
    horizontalListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            hListViewAdapter.setSelectIndex(position);
            aMap.animateCamera(CameraUpdateFactory.newLatLngZoom((LatLng) hotAreaList.get(position), 14));
            addMarkersToMap((LatLng) hotAreaList.get(position), position + 1);
        }
    });
    // 此方法必须重写
    mapView.onCreate(savedInstanceState);
    if (aMap == null) {
        aMap = mapView.getMap();
        CameraUpdate mCameraUpdate = CameraUpdateFactory.zoomTo(14);
        aMap.moveCamera(mCameraUpdate);
        //            aMap.getUiSettings().setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示
        //            aMap.getUiSettings().setCompassEnabled(false);
        aMap.getUiSettings().setScaleControlsEnabled(true);
        didLocation();
        aMap.setOnMarkerClickListener(new AMap.OnMarkerClickListener() {

            @Override
            public boolean onMarkerClick(Marker marker) {
                int index = Integer.parseInt(marker.getSnippet());
                popupInfo(paopaoView, index);
                return true;
            }
        });
        aMap.setOnMapClickListener(new AMap.OnMapClickListener() {

            @Override
            public void onMapClick(LatLng latLng) {
                paopaoView.setVisibility(View.INVISIBLE);
            }
        });
        aMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() {

            @Override
            public void onCameraChange(CameraPosition cameraPosition) {
            }

            @Override
            public void onCameraChangeFinish(CameraPosition cameraPosition) {
                LatLng target = cameraPosition.target;
                if (isFirstInitMap) {
                    isFirstInitMap = false;
                } else {
                //                        getNearParkList(target.longitude + "", target.latitude + "");
                }
            }
        });
    }
    searchEditText.setFocusable(false);
    searchEditText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
        }
    });
    locationButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            didLocation();
        }
    });
}
Also used : AMap(com.amap.api.maps.AMap) ArrayList(java.util.ArrayList) Marker(com.amap.api.maps.model.Marker) MapView(com.amap.api.maps.MapView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) HorizontalListView(com.ningcui.mylibrary.viewLib.HorizontalListView) TextView(android.widget.TextView) CameraPosition(com.amap.api.maps.model.CameraPosition) AdapterView(android.widget.AdapterView) LatLng(com.amap.api.maps.model.LatLng) NaviLatLng(com.amap.api.navi.model.NaviLatLng) HorizontalListViewAdapter(com.litingzhe.justandroid.ui.mapView.adapter.HorizontalListViewAdapter) CameraUpdate(com.amap.api.maps.CameraUpdate)

Example 5 with Marker

use of com.amap.api.maps.model.Marker in project ride-read-android by Ride-Read.

the class PersonalityMapActivity method addMarker.

private void addMarker(LatLng latLng, Bitmap bitmap, Moment moment) {
    if (null == latLng || null == bitmap)
        return;
    MarkerOptions markerOption = new MarkerOptions();
    markerOption.position(latLng);
    //设置Marker可拖动
    markerOption.draggable(false);
    markerOption.icon(BitmapDescriptorFactory.fromBitmap(bitmap));
    // 将Marker设置为贴地显示,可以双指下拉地图查看效果
    //设置marker平贴地图效果
    markerOption.setFlat(true);
    Marker marker = mAMap.addMarker(markerOption);
    marker.setObject(moment);
}
Also used : MarkerOptions(com.amap.api.maps.model.MarkerOptions) Marker(com.amap.api.maps.model.Marker)

Aggregations

Marker (com.amap.api.maps.model.Marker)6 MarkerOptions (com.amap.api.maps.model.MarkerOptions)4 LatLng (com.amap.api.maps.model.LatLng)3 CameraUpdate (com.amap.api.maps.CameraUpdate)2 Point (android.graphics.Point)1 View (android.view.View)1 BounceInterpolator (android.view.animation.BounceInterpolator)1 Interpolator (android.view.animation.Interpolator)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 AMap (com.amap.api.maps.AMap)1 MapView (com.amap.api.maps.MapView)1 Projection (com.amap.api.maps.Projection)1 CameraPosition (com.amap.api.maps.model.CameraPosition)1 TextOptions (com.amap.api.maps.model.TextOptions)1 NaviLatLng (com.amap.api.navi.model.NaviLatLng)1 LatLonPoint (com.amap.api.services.core.LatLonPoint)1 HorizontalListViewAdapter (com.litingzhe.justandroid.ui.mapView.adapter.HorizontalListViewAdapter)1