com.amap.api.maps2d.model.MarkerOptions Java Examples

The following examples show how to use com.amap.api.maps2d.model.MarkerOptions. 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: Waypoint2Activity.java    From Android-GSDemo-Gaode-Map with MIT License 6 votes vote down vote up
private void updateDroneLocation() {

        LatLng pos = new LatLng(mAircraftLat, mAircraftLng);
        //Create MarkerOptions object
        final MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(pos);
        markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.aircraft));

        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (droneMarker != null) {
                    droneMarker.remove();
                }

                if (checkGpsCoordination(mAircraftLat, mAircraftLng)) {
                    droneMarker = aMap.addMarker(markerOptions);
                    droneMarker.setRotateAngle(droneHeading * -1.0f);
                }
            }
        });
    }
 
Example #2
Source File: Waypoint1Activity.java    From Android-GSDemo-Gaode-Map with MIT License 6 votes vote down vote up
private void updateDroneLocation(){

        LatLng pos = new LatLng(droneLocationLat, droneLocationLng);
        //Create MarkerOptions object
        final MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(pos);
        markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.aircraft));

        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (droneMarker != null) {
                    droneMarker.remove();
                }

                if (checkGpsCoordination(droneLocationLat, droneLocationLng)) {
                    droneMarker = aMap.addMarker(markerOptions);
                }
            }
        });
    }
 
Example #3
Source File: FindMapAroundAty.java    From myapplication with Apache License 2.0 6 votes vote down vote up
private MarkerOptions getMarkerOptions(AMapLocation amapLocation) {
        //设置图钉选项
        MarkerOptions options = new MarkerOptions();
        //图标
        options.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_location_on_black_48dp));
        //位置
        options.position(new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude()));
        StringBuffer buffer = new StringBuffer();
        buffer.append(amapLocation.getCountry() + "" + amapLocation.getProvince() + "" +
                amapLocation.getCity() + "" + amapLocation.getDistrict() + "" +
                amapLocation.getStreet() + "" + amapLocation.getStreetNum());
        //标题
        options.title(buffer.toString());
        //子标题
//        options.snippet("I'am Here!");
        //设置多少帧刷新一次图片资源
        options.period(60);

        return options;

    }
 
Example #4
Source File: ShareLocationActivity.java    From sealtalk-android with MIT License 6 votes vote down vote up
private void addMarker(LatLng latLng, String url) {
        AsyncImageView imageView = (AsyncImageView) LayoutInflater.from(this).inflate(R.layout.map_marker_view, null);
//        AsyncImageView imageView = (AsyncImageView) view.findViewById(R.id.icon);
        imageView.setResource(url,0);

//        aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f)
//                .position(new LatLng(30.679879, 104.064855)).title("成都市")
//                .snippet("成都市:30.679879, 104.064855").draggable(true));

        MarkerOptions markerOption = new MarkerOptions();
        markerOption.position(new LatLng(34.341568, 108.940174));
//        markerOption.title("西安市").snippet("西安市:34.341568, 108.940174");
//        markerOption.draggable(true);
//        markerOption.icon(BitmapDescriptorFactory.fromResource(R.drawable.rc_default_portrait));
        markerOption.icon(BitmapDescriptorFactory.fromView(imageView));
//        markerOption.icon(BitmapDescriptorFactory
//                .defaultMarker(BitmapDescriptorFactory.HUE_RED));


        Marker marker2 = aMap.addMarker(markerOption);
        // marker旋转90度
//        marker2.setRotateAngle(90);
    }
 
Example #5
Source File: AMAPLocationActivity.java    From sealtalk-android with MIT License 6 votes vote down vote up
private void addChooseMarker() {
    //加入自定义标签
    MarkerOptions centerMarkerOption = new MarkerOptions().position(myLocation).icon(successDescripter);
    centerMarker = aMap.addMarker(centerMarkerOption);
    centerMarker.setPositionByPixels(mapView.getWidth() / 2, mapView.getHeight() / 2);
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            CameraUpdate update = CameraUpdateFactory.zoomTo(17f);
            aMap.animateCamera(update, 1000, new AMap.CancelableCallback() {
                @Override
                public void onFinish() {
                    aMap.setOnCameraChangeListener(AMAPLocationActivity.this);
                }

                @Override
                public void onCancel() {
                }
            });
        }
    }, 1000);
}
 
Example #6
Source File: AmapActivity.java    From sealtalk-android with MIT License 6 votes vote down vote up
private void addChooseMarker() {
    MarkerOptions centerMarkerOption = new MarkerOptions().position(myLocation).icon(chooseDescripter);
    centerMarker = aMap.addMarker(centerMarkerOption);
    centerMarker.setPositionByPixels(mapView.getWidth() / 2, mapView.getHeight() / 2);
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            CameraUpdate update = CameraUpdateFactory.zoomTo(17f);
            aMap.animateCamera(update, 1000, new AMap.CancelableCallback() {
                @Override
                public void onFinish() {
                    aMap.setOnCameraChangeListener(AmapActivity.this);
                }
                @Override
                public void onCancel() {
                }
            });
        }
    }, 1000);
}
 
Example #7
Source File: Waypoint2Activity.java    From Android-GSDemo-Gaode-Map with MIT License 5 votes vote down vote up
private void markWaypoint(LatLng point) {
    //Create MarkerOptions object
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(point);
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
    Marker marker = aMap.addMarker(markerOptions);
    mMarkers.put(mMarkers.size(), marker);
}
 
Example #8
Source File: MapActivity.java    From xposed-rimet with Apache License 2.0 5 votes vote down vote up
private void addMarkerInScreenCenter(LatLng locationLatLng) {

        LatLng latLng = mAMap.getCameraPosition().target;
        Point screenPosition = mAMap.getProjection().toScreenLocation(latLng);
        mLocationMarker = mAMap.addMarker(new MarkerOptions()
                .anchor(0.5f,0.5f)
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.purple_pin)));

        //设置Marker在屏幕上,不跟随地图移动
        mLocationMarker.setPositionByPixels(screenPosition.x, screenPosition.y);
        mLocationMarker.setZIndex(1);
    }
 
Example #9
Source File: Waypoint1Activity.java    From Android-GSDemo-Gaode-Map with MIT License 5 votes vote down vote up
private void markWaypoint(LatLng point){
    //Create MarkerOptions object
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(point);
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
    Marker marker = aMap.addMarker(markerOptions);
    mMarkers.put(mMarkers.size(), marker);
}
 
Example #10
Source File: Waypoint1Activity.java    From Android-GSDemo-Gaode-Map with MIT License 5 votes vote down vote up
private void initMapView() {

        if (aMap == null) {
            aMap = mapView.getMap();
            aMap.setOnMapClickListener(this);// add the listener for click for amap object
        }

        LatLng shenzhen = new LatLng(22.5362, 113.9454);
        aMap.addMarker(new MarkerOptions().position(shenzhen).title("Marker in Shenzhen"));
        aMap.moveCamera(CameraUpdateFactory.newLatLng(shenzhen));
    }
 
Example #11
Source File: MapSimFragment.java    From AndroidSDK with MIT License 5 votes vote down vote up
@Override
public void onMapClick(LatLng latLng) {
    mCorrectedLatLng = latLng;
    mRealLatLng = getRealLatLng(mCorrectedLatLng);
    mLocationTextView.setText("lon: " + latLng.longitude + "° / lat: " + latLng.latitude + "°");
    mAmap.clear();
    mAmap.addMarker(new MarkerOptions().position(latLng));
    mAmap.animateCamera(CameraUpdateFactory.changeLatLng(latLng));
}
 
Example #12
Source File: MapSimFragment.java    From AndroidSDK with MIT License 5 votes vote down vote up
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    mProgressDialog.dismiss();
    if (aMapLocation != null && aMapLocation.getErrorCode() == 0) {
        mCorrectedLatLng = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude());
        mRealLatLng = getRealLatLng(mCorrectedLatLng);
        mAmap.animateCamera(CameraUpdateFactory.zoomTo(17));
        mAmap.animateCamera(CameraUpdateFactory.changeLatLng(mCorrectedLatLng));
        mLocationTextView.setText("lon: " + aMapLocation.getLongitude() + "° / lat: " + aMapLocation.getLatitude() + "°");
        mAmap.clear();
        mAmap.addMarker(new MarkerOptions().position(mCorrectedLatLng));
    }
}
 
Example #13
Source File: AMAPLocationActivity.java    From sealtalk-android with MIT License 5 votes vote down vote up
private void initAmap() {
    if (aMap == null) {
        aMap = mapView.getMap();
    }

    if (getIntent().hasExtra("location")) {
        isPerview = true;
        mMsg = getIntent().getParcelableExtra("location");
        tvCurLocation.setVisibility(View.GONE);
        returns.setVisibility(View.GONE);

        if (model) {
            CameraPosition location = new CameraPosition.Builder()
                    .target(new LatLng(mMsg.getLat(), mMsg.getLng())).zoom(18).bearing(0).tilt(30).build();
            show(location);
        } else {
            aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f)
                    .position(new LatLng(mMsg.getLat(), mMsg.getLng())).title(mMsg.getPoi())
                    .snippet(mMsg.getLat() + "," + mMsg.getLng()).draggable(false));
        }
        return;
    }


    aMap.setLocationSource(this);// 设置定位监听
    aMap.setMyLocationEnabled(true);
    aMap.getUiSettings().setZoomControlsEnabled(false);
    aMap.getUiSettings().setMyLocationButtonEnabled(false);
    CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(15);//设置缩放监听
    aMap.moveCamera(cameraUpdate);

    successDescripter = BitmapDescriptorFactory.fromResource(R.drawable.icon_usecarnow_position_succeed);
    geocodeSearch = new GeocodeSearch(this);
    geocodeSearch.setOnGeocodeSearchListener(this);
}
 
Example #14
Source File: FindMapAroundAty.java    From myapplication with Apache License 2.0 5 votes vote down vote up
private MarkerOptions getMarkerOptions(int index) {
    return new MarkerOptions()
            .position(
                    new LatLng(mPois.get(index).getLatLonPoint()
                            .getLatitude(), mPois.get(index)
                            .getLatLonPoint().getLongitude()))
            .title(getTitle(index)).snippet(getSnippet(index))
            .icon(getBitmapDescriptor(index));
}
 
Example #15
Source File: ScheduleMapFragment.java    From BetterWay with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化坐标
 */
private void initLatLng() {
    for (int i = 0; i < mLatLngList.size(); i++) {
        Marker marker = mAMap.addMarker(new MarkerOptions());
        marker.setPosition(mLatLngList.get(i));
        marker.setTitle(String.valueOf(i + 1));
        mAMap.moveCamera(CameraUpdateFactory.changeLatLng(mLatLngList.get(0)));
        mAMap.moveCamera(CameraUpdateFactory.zoomTo(13));
    }
}
 
Example #16
Source File: AutoScheduleAssistFragment.java    From BetterWay with Apache License 2.0 5 votes vote down vote up
/**
 * 记录获得点的坐标
 * @param mapMarker 记录的信号
 */
@Subscribe(threadMode = ThreadMode.MAIN)
public void onIntEvent(MapMarker mapMarker) {
    LogUtil.e(TAG, "addToMap()");
    if (mapMarker == MapMarker.ADD) {
        Marker marker = aMap.addMarker(new MarkerOptions());
        marker.setPosition(mLatLng);
        mMarkerList.add(marker);
        LogUtil.d(TAG, "ListLeng =" + mMarkerList.size());
    }
}
 
Example #17
Source File: AMapLiteActivity.java    From XposedRimetHelper with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 添加标记 并移除旧的
 *
 * @param latLng
 * @return
 */
private void addMarker(LatLng latLng, String name) {
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_current_location));
    markerOptions.position(latLng);
    markerOptions.snippet(latLng.latitude + "," + latLng.longitude);
    markerOptions.title(TextUtils.isEmpty(name) ? "未知" : name);
    Marker marker = mAMap.addMarker(markerOptions);

    if (mChooseMarker != null) {
        mChooseMarker.remove();
    }
    mChooseMarker = marker;
}
 
Example #18
Source File: MapActivity.java    From xposed-rimet with Apache License 2.0 5 votes vote down vote up
@Override
public void onLocationChanged(AMapLocation aMapLocation) {

    if (mOnLocationChangedListener == null || mAMapLocationClient == null
            || aMapLocation == null || aMapLocation.getErrorCode() != 0) {
        // 定位失败了
        deactivate();
        ToastUtil.show("定位失败,请开启定位后再重新尝试!");
        return;
    }

    // 当前位置
    LatLng curLatLng = MapUtil.newLatLng(aMapLocation);

    // 通知位置信息
    mOnLocationChangedListener.onLocationChanged(aMapLocation);

    if (mCurMarker == null) {
        // 设置当前位置
        mCurMarker = mAMap.addMarker(new MarkerOptions()
                .anchor(0.5f,0.5f)
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.location_marker)));
    }

    // 移动到指定位置
    mCurMarker.setPosition(curLatLng);

    // 移动到当前位置
    mAMap.animateCamera(CameraUpdateFactory.newLatLngZoom(curLatLng, 16f));
}
 
Example #19
Source File: LocationMapActivity.java    From sealtalk-android with MIT License 4 votes vote down vote up
public void addMarker(LatLng latLng, final UserInfo userInfo) {

        final String url = userInfo.getPortraitUri().toString();

        final MarkerOptions markerOption = new MarkerOptions();

        markerOption.position(latLng);

        View view = LayoutInflater.from(this).inflate(R.layout.rc_icon_rt_location_marker, null);
        AsyncImageView imageView = (AsyncImageView) view.findViewById(android.R.id.icon);
        ImageView locImageView = (ImageView) view.findViewById(android.R.id.icon1);

        if (userInfo.getUserId().equals(RongIMClient.getInstance().getCurrentUserId())) {
            locImageView.setImageResource(R.drawable.rc_rt_loc_myself);
        } else {
            locImageView.setImageResource(R.drawable.rc_rt_loc_other);
        }

        imageView.setResource(url, 0);

        markerOption.anchor(0.5f, 0.5f).icon(BitmapDescriptorFactory.fromView(view));

        Marker marker = getaMap().addMarker(markerOption);
        marker.setObject(userInfo.getUserId());

    }
 
Example #20
Source File: FindMapAroundAty.java    From myapplication with Apache License 2.0 4 votes vote down vote up
@Override
    public void onPoiSearched(PoiResult result, int rcode) {
        if (rcode == 1000) {
            if (result != null && result.getQuery() != null) {// 搜索poi的结果
                if (result.getQuery().equals(query)) {// 是否是同一条
                    poiResult = result;
                    poiItems = poiResult.getPois();// 取得第一页的poiitem数据,页数从数字0开始
                    List<SuggestionCity> suggestionCities = poiResult
                            .getSearchSuggestionCitys();// 当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息
                    if (poiItems != null && poiItems.size() > 0) {
                        //清除POI信息显示
//                        whetherToShowDetailInfo(false);
                        //并还原点击marker样式
                        if (mlastMarker != null) {
                            resetlastmarker();
                        }
                        //清理之前搜索结果的marker
                        if (poiOverlay != null) {
                            poiOverlay.removeFromMap();
                        }
                        aMap.clear();
                        poiOverlay = new MyPoiOverlay(aMap, poiItems);
                        poiOverlay.addToMap();
                        poiOverlay.zoomToSpan();

                        aMap.addMarker(new MarkerOptions()
//                                .anchor(0.5f, 0.5f)
                                .icon(BitmapDescriptorFactory
                                        .fromBitmap(BitmapFactory.decodeResource(
                                                getResources(), R.drawable.point4)))
                                .position(new LatLng(lp.getLatitude(), lp.getLongitude())));

                        aMap.addCircle(new CircleOptions()
                                .center(new LatLng(lp.getLatitude(),
                                        lp.getLongitude())).radius(5000)
                                .strokeColor(Color.BLUE)
                                .fillColor(Color.argb(50, 1, 1, 1))
                                .strokeWidth(2));
//                    } else if (suggestionCities != null
//                            && suggestionCities.size() > 0) {
//                        showSuggestCity(suggestionCities);
                    } else {
                        Toast.makeText(FindMapAroundAty.this,
                                "No Result!", Toast.LENGTH_SHORT).show();
                    }
                }
            } else {
                Toast.makeText(FindMapAroundAty.this,
                        "No Result!", Toast.LENGTH_SHORT).show();
            }
        }

    }