Java Code Examples for com.amap.api.maps.model.MarkerOptions#icon()

The following examples show how to use com.amap.api.maps.model.MarkerOptions#icon() . 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: MainActivity.java    From Android_UsingCar_Example with Apache License 2.0 6 votes vote down vote up
@Override
public void onMapLoaded() {

	MarkerOptions markerOptions = new MarkerOptions();
	markerOptions.setFlat(true);
	markerOptions.anchor(0.5f, 0.5f);
	markerOptions.position(new LatLng(0, 0));
	markerOptions
			.icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory
					.decodeResource(getResources(),
							R.drawable.icon_loaction_start)));
	mPositionMark = mAmap.addMarker(markerOptions);

	mPositionMark.setPositionByPixels(mMapView.getWidth() / 2,
			mMapView.getHeight() / 2);
	mLocationTask.startSingleLocate();
}
 
Example 2
Source File: BusLineOverlay.java    From TraceByAmap with MIT License 6 votes vote down vote up
private MarkerOptions getMarkerOptions(int index) {
    MarkerOptions options = new MarkerOptions()
            .position(
                    new LatLng(mBusStations.get(index).getLatLonPoint()
                            .getLatitude(), mBusStations.get(index)
                            .getLatLonPoint().getLongitude()))
            .title(getTitle(index)).snippet(getSnippet(index));
    if (index == 0) {
        options.icon(getStartBitmapDescriptor());
    } else if (index == mBusStations.size() - 1) {
        options.icon(getEndBitmapDescriptor());
    } else {
        options.anchor(0.5f, 0.5f);
        options.icon(getBusBitmapDescriptor());
    }
    return options;
}
 
Example 3
Source File: BusLineOverlay.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
private MarkerOptions getMarkerOptions(int index) {
    MarkerOptions options = new MarkerOptions()
            .position(
                    new LatLng(mBusStations.get(index).getLatLonPoint()
                            .getLatitude(), mBusStations.get(index)
                            .getLatLonPoint().getLongitude()))
            .title(getTitle(index)).snippet(getSnippet(index));
    if (index == 0) {
        options.icon(getStartBitmapDescriptor());
    } else if (index == mBusStations.size() - 1) {
        options.icon(getEndBitmapDescriptor());
    } else {
        options.anchor(0.5f, 0.5f);
        options.icon(getBusBitmapDescriptor());
    }
    return options;
}
 
Example 4
Source File: BusLineOverlay.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
private MarkerOptions getMarkerOptions(int index) {
    MarkerOptions options = new MarkerOptions()
            .position(
                    new LatLng(mBusStations.get(index).getLatLonPoint()
                            .getLatitude(), mBusStations.get(index)
                            .getLatLonPoint().getLongitude()))
            .title(getTitle(index)).snippet(getSnippet(index));
    if (index == 0) {
        options.icon(getStartBitmapDescriptor());
    } else if (index == mBusStations.size() - 1) {
        options.icon(getEndBitmapDescriptor());
    } else {
        options.anchor(0.5f, 0.5f);
        options.icon(getBusBitmapDescriptor());
    }
    return options;
}
 
Example 5
Source File: FlutterAMapView.java    From flutter_amap_plugin with MIT License 6 votes vote down vote up
private void initAnnotations() throws IOException {
    if (aMap == null) {
        aMap = mapView.getMap();
    }
    aMap.setOnInfoWindowClickListener(this);
    this.annotations.clear();
    this.positions.clear();
    for (AMapAnnotationModel coor :
            this.annotationOptions.annotationCoordinates) {
        MarkerOptions markerOption = new MarkerOptions()
                .position(coor.coordinate.toLatLng())
                .draggable(annotationOptions.draggable)
                .title(coor.title)
                .snippet(coor.subTitle);
        if (coor.annotationIcon != null) {
            markerOption.icon(PluginAssets.assetpath(coor.annotationIcon));
        } else {
            if (this.annotationOptions.annotationIcon != null) {
                markerOption.icon(PluginAssets.assetpath(this.annotationOptions.annotationIcon));
            }
        }
        this.annotations.add(markerOption);
        this.positions.add(coor.coordinate.toLatLng());
    }
    aMap.addMarkers(this.annotations, true);
}
 
Example 6
Source File: MapActivity.java    From TestChat with Apache License 2.0 5 votes vote down vote up
private void addMarkerOnMap(String message) {
        if (mMarker == null) {
                LogUtil.e("这里设置图标选项");
                mOptions = new MarkerOptions();
                mOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
                mOptions.snippet(message);
                mOptions.position(new LatLng(latitude, longitude));
                mMarker = mMap.addMarker(mOptions);
        }
        mMap.reloadMap();
        startMarkerAnimation();
}
 
Example 7
Source File: PlaceMapFragment.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
public void addMarker(PlaceBrief place) {
    MarkerOptions markerOption = new MarkerOptions();
    markerOption.position(new LatLng(place.getLat(), place.getLng()));
    markerOption.title(place.getName()).snippet(place.getAddressBrief());
    markerOption.icon(BitmapDescriptorFactory
            .fromResource(place.getCostType() == 0 ? R.drawable.location_point_green : R.drawable.location_point_red));
    Marker marker = aMap.addMarker(markerOption);
    marker.setToTop();
    mMarkerMap.put(marker, place);
    if (mMarkerMap.size() < MIN_ZOOM_MARKER_COUNT+1) zoomMarkerList.add(place);
    if (mMarkerMap.size()== MIN_ZOOM_MARKER_COUNT+1) moveToAdjustPlace(zoomMarkerList);
}
 
Example 8
Source File: PlaceMapFragment.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
private void initMyPoint() {
    MarkerOptions markerOption = new MarkerOptions();
    markerOption.icon(BitmapDescriptorFactory
            .fromResource(R.drawable.location_marker));
    mMyLocation = aMap.addMarker(markerOption);
    LocationModel.getInstance().registerLocationChange(location -> {
        JUtils.Log("latitude"+location.latitude+"  longitude"+location.longitude);
        mMyLocation.setPosition(new LatLng(location.latitude, location.longitude));
    });
}
 
Example 9
Source File: PlaceLocationSelectActivity.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onMapClick(LatLng latLng) {
    if (mLastMarker != null) mLastMarker.destroy();
    mPoint = latLng;
    MarkerOptions markerOption = new MarkerOptions();
    markerOption.position(latLng);
    markerOption.icon(BitmapDescriptorFactory
            .fromResource(R.drawable.location_point_bigger_red));
    mLastMarker = aMap.addMarker(markerOption);
    mGeocoderSearch.getFromLocationAsyn(new RegeocodeQuery(new LatLonPoint(latLng.latitude,latLng.longitude), 50,GeocodeSearch.AMAP));
}
 
Example 10
Source File: PlaceLocationSelectActivity.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
private void initMyPoint() {
    Location location = LocationModel.getInstance().getCurLocation();
    moveTo(location.getLatitude(), location.getLongitude(), 13);
    mGeocoderSearch.getFromLocationAsyn(new RegeocodeQuery(new LatLonPoint(location.getLatitude(), location.getLongitude()), 50, GeocodeSearch.AMAP));

    MarkerOptions markerOption = new MarkerOptions();
    markerOption.icon(BitmapDescriptorFactory
            .fromResource(R.drawable.location_marker));
    mMyLocation = aMap.addMarker(markerOption);
    mPoint = new LatLng(location.getLatitude(),location.getLongitude());
    LocationModel.getInstance().registerLocationChange(newLocation -> mMyLocation.setPosition(new LatLng(location.latitude,location.longitude)));
}
 
Example 11
Source File: PlaceMapPathActivity.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
public void initPlacePoint() {
    MarkerOptions markerOption = new MarkerOptions();
    JUtils.Log("Place" + mPlaceDetail.getLat() + ":" + mPlaceDetail.getLng());
    markerOption.position(new LatLng(mPlaceDetail.getLat(), mPlaceDetail.getLng()));
    markerOption.title(mPlaceDetail.getName()).snippet(mPlaceDetail.getAddressBrief());
    markerOption.icon(BitmapDescriptorFactory
            .fromResource(mPlaceDetail.getCostType() == 0 ? R.drawable.location_point_green : R.drawable.location_point_red));
    mPlaceLocation = mAMap.addMarker(markerOption);
}
 
Example 12
Source File: PlaceMapPathActivity.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
private void initMyPoint() {
    MarkerOptions markerOption = new MarkerOptions();
    markerOption.icon(BitmapDescriptorFactory
            .fromResource(R.drawable.location_marker));
    markerOption.title("我的位置")
    ;
    mMyLocation = mAMap.addMarker(markerOption);
    LocationModel.getInstance().registerLocationChange(location -> {
        mMyLocation.setPosition(new LatLng(location.latitude,location.longitude));
        mMyLocation.setSnippet(location.getAddress());
    });
}
 
Example 13
Source File: AMapMarker.java    From react-native-amap with MIT License 5 votes vote down vote up
private MarkerOptions createMarkerOptions() {
    MarkerOptions options = new MarkerOptions();
    if (anchorIsSet) options.anchor(anchorX, anchorY);
    //if (calloutAnchorIsSet) options.infoWindowAnchor(calloutAnchorX, calloutAnchorY);
    options.position(position);
    options.title(title);
    options.snippet(snippet);
    options.rotateAngle(rotation);
    options.setFlat(flat);
    options.draggable(draggable);
    options.zIndex(zIndex);
    options.alpha(opacity);
    options.icon(getIcon());
    return options;
}
 
Example 14
Source File: MapDrawer.java    From RunMap with Apache License 2.0 5 votes vote down vote up
public void drawSingleMaker(LatLng latLng, String title, int iconId) {
    if (iconId != -1) {
        MarkerOptions options = new MarkerOptions().position(latLng).title(title);
        options.icon(BitmapDescriptorFactory.fromResource(iconId));
        mAmap.addMarker(options);
    } else {
        mAmap.addMarker(new MarkerOptions().position(latLng).title(title).snippet("DefaultMarker"));
    }
}
 
Example 15
Source File: MapActivity.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
private void addMarkerOnMap(String message) {
    if (mMarker == null) {
        LogUtil.e("这里设置图标选项");
        MarkerOptions mOptions = new MarkerOptions();
        mOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
        mOptions.snippet(message);
        mOptions.position(new LatLng(latitude, longitude));
        mMarker = mMap.addMarker(mOptions);
    }
    mMap.reloadMap();
    startMarkerAnimation();
}
 
Example 16
Source File: MapActivity.java    From WechatHook-Dusan with Apache License 2.0 5 votes vote down vote up
private void addCenterMarker(LatLng latlng) {
    if (null == centerMarker) {
        markerOption = new MarkerOptions();
        markerOption.icon(ICON_RED);//ICON_RED  ICON_YELLOW
        centerMarker = amap.addMarker(markerOption);
        centerMarker.setPosition(latlng);
        centerMarker.setTitle("当前坐标:"+longitude+","+latitude+"\n"+formatAddress);
    }
}
 
Example 17
Source File: MapActivity.java    From TikTok with Apache License 2.0 5 votes vote down vote up
private void initMarks() {

        MarkerOptions markerOption = new MarkerOptions();
        markerOption.position(latlng);
        markerOption.title("西安市").snippet("西安市:34.341568, 108.940174");

        markerOption.draggable(true);//设置Marker可拖动
        markerOption.icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory
                .decodeResource(getResources(),R.mipmap.ic_launcher)));
        // 将Marker设置为贴地显示,可以双指下拉地图查看效果
        markerOption.setFlat(true);//设置marker平贴地图效果

        mAMap.addMarker(markerOption);

    }
 
Example 18
Source File: PoiClickActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 *  底图poi点击回调
 */
@Override
public void onPOIClick(Poi poi) {
	mAMap.clear();
	Log.i("MY", poi.getPoiId()+poi.getName());
	MarkerOptions markOptiopns = new MarkerOptions();
	markOptiopns.position(poi.getCoordinate());
	TextView textView = new TextView(getApplicationContext());
	textView.setText("到"+poi.getName()+"去");
	textView.setGravity(Gravity.CENTER);
	textView.setTextColor(Color.BLACK);
	textView.setBackgroundResource(R.drawable.custom_info_bubble);
	markOptiopns.icon(BitmapDescriptorFactory.fromView(textView));
	mAMap.addMarker(markOptiopns);
}
 
Example 19
Source File: ShareActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 添加marker方法
 * 
 * @param lat
 * @param lon
 * @param title
 * @param snippet
 * @param icon
 */
private void addMarker(double lat, double lon, String title,
		String snippet, BitmapDescriptor icon) {
	MarkerOptions markerOption = new MarkerOptions();
	LatLng markerPoint = new LatLng(lat, lon);
	markerOption.position(markerPoint);
	markerOption.title(title).snippet(snippet);
	markerOption.icon(icon);
	mAMap.addMarker(markerOption);
}
 
Example 20
Source File: CustomMarkerActivity.java    From TraceByAmap with MIT License 4 votes vote down vote up
/**
 * 在地图上添加marker
 */
private void addMarkersToMap() {
	// 文字显示标注,可以设置显示内容,位置,字体大小颜色,背景色旋转角度
	TextOptions textOptions = new TextOptions()
			.position(Constants.BEIJING)
			.text("Text")
			.fontColor(Color.BLACK)
			.backgroundColor(Color.BLUE)
			.fontSize(30)
			.rotate(20)
			.align(Text.ALIGN_CENTER_HORIZONTAL, Text.ALIGN_CENTER_VERTICAL)
			.zIndex(1.f).typeface(Typeface.DEFAULT_BOLD);
	aMap.addText(textOptions);

	Marker marker = aMap.addMarker(new MarkerOptions()

			.title("好好学习")
			.icon(BitmapDescriptorFactory
					.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
			.draggable(true));
	marker.setRotateAngle(90);// 设置marker旋转90度
	marker.setPositionByPixels(400, 400);
	marker.showInfoWindow();// 设置默认显示一个infowinfow

	markerOption = new MarkerOptions();
	markerOption.position(Constants.XIAN);
	markerOption.title("西安市").snippet("西安市:34.341568, 108.940174");

	markerOption.draggable(true);
	markerOption.icon(
	// BitmapDescriptorFactory
	// .fromResource(R.drawable.location_marker)
			BitmapDescriptorFactory.fromBitmap(BitmapFactory
					.decodeResource(getResources(),
							R.drawable.location_marker)));
	// 将Marker设置为贴地显示,可以双指下拉看效果
	markerOption.setFlat(true);

	ArrayList<BitmapDescriptor> giflist = new ArrayList<BitmapDescriptor>();
	giflist.add(BitmapDescriptorFactory
			.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
	giflist.add(BitmapDescriptorFactory
			.defaultMarker(BitmapDescriptorFactory.HUE_RED));
	giflist.add(BitmapDescriptorFactory
			.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW));

	MarkerOptions markerOption1 = new MarkerOptions().anchor(0.5f, 0.5f)
			.position(Constants.CHENGDU).title("成都市")
			.snippet("成都市:30.679879, 104.064855").icons(giflist)
			.draggable(true).period(10);
	ArrayList<MarkerOptions> markerOptionlst = new ArrayList<MarkerOptions>();
	markerOptionlst.add(markerOption);
	markerOptionlst.add(markerOption1);
	List<Marker> markerlst = aMap.addMarkers(markerOptionlst, true);
	marker2 = markerlst.get(0);

	marker3 = aMap.addMarker(new MarkerOptions().position(
			Constants.ZHENGZHOU).icon(
			BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)));
}