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

The following examples show how to use com.amap.api.maps.model.MarkerOptions#position() . 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: 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 3
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 4
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 5
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 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: 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 8
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 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: 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 11
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)));
}