• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MapView类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.tencent.tencentmap.mapsdk.map.MapView的典型用法代码示例。如果您正苦于以下问题:Java MapView类的具体用法?Java MapView怎么用?Java MapView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MapView类属于com.tencent.tencentmap.mapsdk.map包,在下文中一共展示了MapView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: draw

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
@Override
public void draw(Canvas canvas, MapView mapView) {
	if (geoPoint == null) {
		return;
	}
	Projection mapProjection = mapView.getProjection();
	Paint paint = new Paint();
	Point ptMap = mapProjection.toPixels(geoPoint, null);
	paint.setColor(Color.BLUE);
	paint.setAlpha(8);
	paint.setAntiAlias(true);

	float fRadius = mapProjection.metersToEquatorPixels(fAccuracy);
	canvas.drawCircle(ptMap.x, ptMap.y, fRadius, paint);
	paint.setStyle(Style.STROKE);
	paint.setAlpha(200);
	canvas.drawCircle(ptMap.x, ptMap.y, fRadius, paint);

	if (bmpMarker != null) {
		paint.setAlpha(255);
		canvas.drawBitmap(bmpMarker, ptMap.x - bmpMarker.getWidth() / 2,
				ptMap.y - bmpMarker.getHeight() / 2, paint);
	}

	super.draw(canvas, mapView);
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:27,代码来源:DemoMapActivity.java


示例2: onTap

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
@Override
public void onTap(OverlayItem itemTap, String address) {
	// TODO Auto-generated method stub
	if (viewTip == null || itemTap == null) {
		return;
	}
	addressTv.setText(address);
	MapView.LayoutParams layParaOntap = new MapView.LayoutParams(
			MapView.LayoutParams.WRAP_CONTENT,
			MapView.LayoutParams.WRAP_CONTENT, itemTap.getPoint(),
			iTipTranslateX, -iTipTranslateY,
			MapView.LayoutParams.BOTTOM_CENTER);
	if (mMapView.indexOfChild(viewTip) == -1) {
		mMapView.addView(viewTip, layParaOntap);
	} else {
		mMapView.updateViewLayout(viewTip, layParaOntap);
	}
}
 
开发者ID:kk-java,项目名称:MarkerDragForTencentMap,代码行数:19,代码来源:ItemizedOverlayDemo.java


示例3: draw

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
@Override
public void draw(Canvas canvas, MapView mapView) {

	// Projection接口用于屏幕像素点坐标系统和地球表面经纬度点坐标系统之间的变换
	Projection projection = mapView.getProjection();
	for (int index = size() - 1; index >= 0; index--) { // 遍历GeoList
		OverlayItem overLayItem = getItem(index); // 得到给定索引的item

		String title = overLayItem.getTitle();
		// 把经纬度变换到相对于MapView左上角的屏幕像素坐标
		Point point = projection.toPixels(overLayItem.getPoint(), null);

		Paint paintCircle = new Paint();
		paintCircle.setColor(Color.RED);
		canvas.drawCircle(point.x, point.y, 5, paintCircle); // 画圆

		Paint paintText = new Paint();
		paintText.setColor(Color.BLACK);
		paintText.setTextSize(15);
		canvas.drawText(title, point.x, point.y - 25, paintText); // 绘制文本

	}

	super.draw(canvas, mapView);
}
 
开发者ID:kk-java,项目名称:MarkerDragForTencentMap,代码行数:26,代码来源:ItemizedOverlayDemo.java


示例4: drawPolyline

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
private void drawPolyline(Canvas canvas, MapView mapView)
{
	Point ptLine1=mapView.getProjection().toPixels(geoPolyLine1, null);
	Point ptLine2=mapView.getProjection().toPixels(geoPolyLine2, null);
	Point ptLine3=mapView.getProjection().toPixels(geoPolyLine3, null);
	Point ptLine4=mapView.getProjection().toPixels(geoPolyLine4, null);
	
	Path pathLine=new Path();
	pathLine.moveTo(ptLine1.x, ptLine1.y);
	pathLine.lineTo(ptLine2.x, ptLine2.y);
	pathLine.lineTo(ptLine3.x, ptLine3.y);
	pathLine.lineTo(ptLine4.x, ptLine4.y);
	
	Paint paintLine=new Paint();
	paintLine.setStyle(Style.STROKE);
	paintLine.setStrokeWidth(10);
	paintLine.setColor(Color.BLUE);
	paintLine.setAntiAlias(true);
	paintLine.setStrokeCap(Cap.ROUND);
	paintLine.setStrokeJoin(Join.ROUND);
	
	canvas.drawPath(pathLine, paintLine);
}
 
开发者ID:kk-java,项目名称:MarkerDragForTencentMap,代码行数:24,代码来源:OverlayDemo.java


示例5: drawPolygon

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
private void drawPolygon(Canvas canvas, MapView mapView)
{
	Point ptpolygon1=mapView.getProjection().toPixels(geoPolygon1, null);
	Point ptpolygon2=mapView.getProjection().toPixels(geoPolygon2, null);
	Point ptpolygon3=mapView.getProjection().toPixels(geoPolygon3, null);
	Point ptpolygon4=mapView.getProjection().toPixels(geoPolygon4, null);
	
	Path pathpolygon=new Path();
	pathpolygon.moveTo(ptpolygon1.x, ptpolygon1.y);
	pathpolygon.lineTo(ptpolygon2.x, ptpolygon2.y);
	pathpolygon.lineTo(ptpolygon3.x, ptpolygon3.y);
	pathpolygon.lineTo(ptpolygon4.x, ptpolygon4.y);
	
	Paint paintpolygon=new Paint();
	paintpolygon.setStyle(Style.FILL);
	paintpolygon.setStrokeWidth(10);
	paintpolygon.setColor(Color.BLUE);
	paintpolygon.setAntiAlias(true);
	paintpolygon.setStrokeCap(Cap.ROUND);
	paintpolygon.setStrokeJoin(Join.ROUND);
	
	canvas.drawPath(pathpolygon, paintpolygon);
}
 
开发者ID:kk-java,项目名称:MarkerDragForTencentMap,代码行数:24,代码来源:OverlayDemo.java


示例6: initMapView

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
private void initMapView() {
	mMapView = (MapView) findViewById(R.id.mapviewOverlay);
	mMapView.setBuiltInZoomControls(true);
	mMapView.getController().setZoom(9);

	Bitmap bmpMarker = BitmapFactory.decodeResource(getResources(),
			R.drawable.mark_location);
	mLocationOverlay = new LocationOverlay(bmpMarker);
	mMapView.addOverlay(mLocationOverlay);
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:11,代码来源:DemoMapActivity.java


示例7: initUi

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
private void initUi() {
	// poi item & poi overlay
	mFenceItems = DemoGeofenceApp.getFenceItems();
	mFenceOverlay = new PoiOverlay(getResources().getDrawable(
			R.drawable.sendtocar_balloon));
	mFenceOverlay.setPoiItems(mFenceItems);

	// mapview
	mMapView = (MapView) findViewById(R.id.map);
	mMapView.addOverlay(mFenceOverlay);
	mMapView.setOnTouchListener(this);

	// list & adapter
	mPosition = (TextView) findViewById(R.id.position);
	mFenceList = (ListView) findViewById(R.id.geofence_list);

	mFenceListAdapter = new ArrayAdapter<TencentGeofence>(this,
			android.R.layout.simple_list_item_checked,
			DemoGeofenceApp.getFence()) {
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			TencentGeofence geofence = getItem(position);
			TextView tv = (TextView) super.getView(position, convertView,
					parent);
			tv.setText(Utils.toString(geofence));
			return tv;
		}
	};
	mFenceList.setAdapter(mFenceListAdapter);
	mFenceList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

	updatePosition();
}
 
开发者ID:tencentlocation,项目名称:TencentLocationDemo,代码行数:34,代码来源:DemoGeofenceEditorActivty.java


示例8: initView

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
private void initView() {
    mMapView = (MapView) findViewById(android.R.id.widget_frame);
    mTitle = (TextView) findViewById(android.R.id.title);
    mButton = (Button) this.findViewById(android.R.id.button1);
    mMapController = mMapView.getController();

}
 
开发者ID:yangyunfeng666,项目名称:demo-app-android-v2-2.3.9,代码行数:8,代码来源:SOSOLocationActivity.java


示例9: onCreate

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
@Override
	/**
	 *显示地图,启用内置缩放控件,并用MapController控制地图的中心点及Zoom级别
	 */
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.routesearchdemo);
		mMapView = (MapView) findViewById(R.id.mapviewroutesearch);
		
		btnRouteSearch = (Button) this.findViewById(R.id.btnRouteSearch);
		btnRouteSearch.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				searchBusRoute();
//				searchDriveRoute();
				
			}
		});
		
		mMapView.setBuiltInZoomControls(true); // 设置启用内置的缩放控件
		GeoPoint point = new GeoPoint((int) (39.90923 * 1E6), (int) (116.397428 * 1E6)); // 用给定的经纬度构造一个GeoPoint,单位是微度
										
		mMapView.getController().setCenter(point); 
		mMapView.getController().setZoom(9);
		mMapView.setBuiltInZoomControls(false);
	}
 
开发者ID:kk-java,项目名称:MarkerDragForTencentMap,代码行数:29,代码来源:RouteSearchDemo.java


示例10: onCreate

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);

	requestWindowFeature(Window.FEATURE_NO_TITLE);
	getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
			WindowManager.LayoutParams.FLAG_FULLSCREEN);
	setContentView(R.layout.itemizedoverlay);

	LayoutInflater layoutInfla = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
	viewTip = layoutInfla.inflate(R.layout.layouttipview, null);
	addressTv = (TextView) viewTip.findViewById(R.id.txtViewSelectSub);

	mMapView = (MapView) findViewById(R.id.itemizedoverlayview);
	mMapView.setBuiltInZoomControls(true); // 设置启用内置的缩放控件
	mMapController = mMapView.getController();

	Drawable marker = getResources().getDrawable(R.drawable.markpoint); // 得到需要标在地图上的资源

	this.iTipTranslateY = marker.getIntrinsicHeight();

	marker.setBounds(0, 0, marker.getIntrinsicWidth(),
			marker.getIntrinsicHeight()); // 为maker定义位置和边界

	mapOverlay = new MapOverlay(marker, this);
	mapOverlay.setOnTapListener(onTapListener);
	mMapView.addOverlay(mapOverlay); // 添加标注,可以通过mMapView.getOverlays().remove删除标注,删除后可以通过mapview.refreshMap()刷新地图
										// 添加ItemizedOverlay实例到mMapView
	mMapView.invalidate(); // 刷新地图
	
	mMapController.animateTo(mapOverlay.getCenter());
	
	
}
 
开发者ID:kk-java,项目名称:MarkerDragForTencentMap,代码行数:36,代码来源:ItemizedOverlayDemo.java


示例11: onCreate

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
@Override
/**
 *显示地图,启用内置缩放控件,并用MapController控制地图的中心点及Zoom级别
 */
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.overlaydemo);
	mMapView = (MapView) findViewById(R.id.mapviewOverlay);
	
	mMapView.setBuiltInZoomControls(true); // 设置启用内置的缩放控件 
	mMapView.getController().setZoom(9);
	
	Bitmap bmpMarker=null;
	Resources res=OverlayDemo.this.getResources();
	bmpMarker=BitmapFactory.decodeResource(res, R.drawable.mark_location);
	
	SimulateLocationOverlay simuOvelay=new SimulateLocationOverlay(bmpMarker);
	mMapView.addOverlay(simuOvelay);
	
	GeoPoint geoSimulateLocation=new GeoPoint((int)(39.984297*1e6), (int)(116.307523*1e6));
	simuOvelay.setGeoCoords(geoSimulateLocation);
	simuOvelay.setAccuracy(5000);
	
	
	GraphicOverlay garphicOverlay=new GraphicOverlay();
	mMapView.addOverlay(garphicOverlay);
}
 
开发者ID:kk-java,项目名称:MarkerDragForTencentMap,代码行数:28,代码来源:OverlayDemo.java


示例12: draw

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
@Override
public void draw(Canvas canvas, MapView mapView) {
	if(geoPoint==null)
	{
		return;
	}
	Projection mapProjection = mapView.getProjection();
	Paint paint = new Paint();
	Point ptMap = mapProjection.toPixels(geoPoint, null);
	paint.setColor(Color.BLUE);
	paint.setAlpha(8);
	paint.setAntiAlias(true);

	float fRadius=mapProjection.metersToEquatorPixels(fAccuracy);
	canvas.drawCircle(ptMap.x, ptMap.y, fRadius, paint);
	paint.setStyle(Style.STROKE);
	paint.setAlpha(200);
	canvas.drawCircle(ptMap.x, ptMap.y, fRadius, paint);

	if(bmpMarker!=null)
	{
		paint.setAlpha(255);
		canvas.drawBitmap(bmpMarker, ptMap.x - bmpMarker.getWidth() / 2, ptMap.y
				- bmpMarker.getHeight() / 2, paint);
	}
	
	super.draw(canvas, mapView);
}
 
开发者ID:kk-java,项目名称:MarkerDragForTencentMap,代码行数:29,代码来源:OverlayDemo.java


示例13: onCreate

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_route_map);


    Route route = null;
    // 读取路线信息
    for (Route r : allRoutes) {
        if (r.getId() == getIntent().getIntExtra("route", 0)) {
            route = r;
            break;
        }
    }

    mMapView = (MapView) findViewById(R.id.mapview);
    TencentMap tencentMap = mMapView.getMap();
    tencentMap.setZoom(route.getZoom());

    double initLongitude = 0;
    double initLatitude = 0;

    for (Marker marker : route.getMarkers()) {
        LatLng startPos = new LatLng(marker.getLongitude(), marker.getLatitude());
        com.tencent.mapsdk.raster.model.Marker m = tencentMap.addMarker(new MarkerOptions()
                .position(startPos)
                .title(marker.getTitle() + " - " + marker.getSnippet())
                .snippet(marker.getMethod() + " (" + marker.getTime() + ")")
                .anchor(.5f, .5f)
                .draggable(false)
                .icon(BitmapDescriptorFactory.defaultMarker()));
        m.showInfoWindow();

        initLatitude += marker.getLatitude();
        initLongitude += marker.getLongitude();
    }

    tencentMap.setCenter(new LatLng(initLongitude / route.getMarkers().size(), initLatitude / route.getMarkers().size()));

    UiSettings uiSettings = mMapView.getUiSettings();
    // 启动缩放手势
    uiSettings.setZoomGesturesEnabled(true);
    uiSettings.setAnimationEnabled(true);
}
 
开发者ID:yuhodev,项目名称:login,代码行数:45,代码来源:RouteMap.java


示例14: onTouchEvent

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent arg0, MapView arg1) {

	if (isLongClickMarker && (arg0.getAction() == MotionEvent.ACTION_UP)) {
		
		isLongClickMarker = false;
		
		// 得到拖动停止的位置
		OverlayItem oi = getItem(0);

		ReGeocoderResult regeocoderResult = null;
		try {

			arg1.getController().animateTo(oi.getPoint());
			regeocoderResult = geocodersearcher.searchFromLocation(oi
					.getPoint());

			// String nextLine = System.getProperty("line.separator");
			//
			// if(regeocoderResult.addresslist!=null)
			// {
			// int iAddrSize=regeocoderResult.addresslist.size();
			// strResult+="addresslist size="+iAddrSize+nextLine;
			// if(iAddrSize>0)
			// {
			// ReGeocoderAddress addr=regeocoderResult.addresslist.get(0);
			// strResult+="address name="+addr.name+nextLine;
			// strResult+="address type="+addr.type+nextLine;
			// strResult+="address dist="+addr.dist+nextLine;
			// strResult+="address adcode="+addr.adcode+nextLine;
			// strResult+="address point="+addr.point.toString()+nextLine;
			// }
			// }
			// if(regeocoderResult.poilist!=null)
			// {
			// int iPoiSize=regeocoderResult.poilist.size();
			// strResult+="poilist size="+iPoiSize+nextLine;
			// if(iPoiSize>0)
			// {
			// PoiItem poi=regeocoderResult.poilist.get(0);
			// strResult+="poi name="+poi.name+nextLine;
			// strResult+="poi address="+poi.address+nextLine;
			// strResult+="poi classes="+poi.classes+nextLine;
			// strResult+="poi phone="+poi.phone+nextLine;
			// strResult+="poi point="+poi.point.toString()+nextLine;
			// }
			// }

			if (regeocoderResult.poilist != null) {
				int iPoiSize = regeocoderResult.poilist.size();
				if (iPoiSize > 0) {
					PoiItem poi = regeocoderResult.poilist.get(0);
					strResult = poi.address + poi.name;
				}
			}

			System.out.println(strResult);
			onTap(0);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	return super.onTouchEvent(arg0, arg1);
}
 
开发者ID:kk-java,项目名称:MarkerDragForTencentMap,代码行数:65,代码来源:ItemizedOverlayDemo.java


示例15: onLongPress

import com.tencent.tencentmap.mapsdk.map.MapView; //导入依赖的package包/类
@Override
public boolean onLongPress(GeoPoint p, MotionEvent event, MapView mapView) {
	// TODO Auto-generated method stub
	isLongClickMarker = true;
	return super.onLongPress(p, event, mapView);
}
 
开发者ID:kk-java,项目名称:MarkerDragForTencentMap,代码行数:7,代码来源:ItemizedOverlayDemo.java



注:本文中的com.tencent.tencentmap.mapsdk.map.MapView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XSUnionSimpleType类代码示例发布时间:2022-05-23
下一篇:
Java Conduit类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap