GeoPoint p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
OverlayItem item = new OverlayItem(p, "", "");
item.setMarker(getResources().getDrawable(id));
解决方案 »
- 关于处理Handler处理耗时的下载任务的问题
- Androidmanifest.xml 中遇到的问题
- 安卓视频刻录
- flash文件在android 2.0的屏上能不能显示
- 我把android.jar包进行反编译,为什么只有方法而没有实现
- Android2.2 联系人,添加一个分组,查看此分组,添加成员,选择合并的联系人,完成,提示组员已添加,实际未添加成功。
- 关于Scrollview滑动如何跟Gridview一样快速
- 手机休眠状态下,alarmmanager不准的问题
- 安卓类似于朋友圈的评论功能,当点击评论是从底部弹出输入框,求大家指点下。
- Android Studio .cpp文件图标是什么意思
- 如何创建指定分辨率的浏览视图
- Android 开发求助:unfortunately, ApplicationName has stoped
(int) (locationDataInfo.getData().latitude * 1E6),
(int) (locationDataInfo.getData().longitude * 1E6));
// 用给定的经纬度构造一个GeoPoint,单位是微度 (度 * 1E6)
mMapController.setCenter(point);// 设置地图中心点
mMapController.setZoom(18);// 设置地图zoom级别
Drawable er = BaiduMapLocationActivity.this
.getResources().getDrawable(R.drawable.location);
OverlayItem overlayItem = new OverlayItem(point, "位置",
"位置");
ItemizedOverlay<OverlayItem> overlay = new ItemizedOverlay<OverlayItem>(
er, mMapView);
overlay.addItem(overlayItem);
mMapView.getOverlays().clear();
mMapView.getOverlays().add(overlay);
mMapView.refresh();
mBMapMan.start();谷歌地图:latLng = new LatLng(locationDataInfo.getData().latitude,
locationDataInfo.getData().longitude);
cameraPosition = new CameraPosition(latLng, 18, 0, 0);
MapsInitializer.initialize(GoogleMapLocationActivity.this);
cameraUpdate = CameraUpdateFactory
.newCameraPosition(cameraPosition);
googleMap.moveCamera(cameraUpdate);
googleMap.clear();
setUpMap(locationDataInfo.getData().latitude,
locationDataInfo.getData().longitude);
GraphicsLayer graphicsLayer = new GraphicsLayer();
mapView.addLayer(graphicsLayer);Point loc= new Point(120.8664698600769,36.14800174970085); //获取的定位
SpatialReference sr4326 = SpatialReference.create(SpatialReference.WKID_WGS84);
Point p = (Point)GeometryEngine.project(loc, sr4326, mapView.getSpatialReference()); //转为地图坐标Drawable drawable = Drawable.createFromPath("/mnt/sdcard/lcon.png"); //Icon.png 是个图标
PictureMarkerSymbol picSymbol = new PictureMarkerSymbol(drawable);Graphic g= new Graphic(p, picSymbol);
graphicsLayer.addGraphic(g);
我再oncreat中写会显示,但是将他放在一个方法里,通过按钮点击的话,就不会实现,因为什么啊?算不出来,哈,贴来看看?
算不出来,哈,贴来看看?Drawable drawable = getResources().getDrawable(R.drawable.arrow);
PictureMarkerSymbol picSymbol = new PictureMarkerSymbol(drawable);
Point loc= new Point(1.4191862462692365E7,5183685.4328131145); //获取的定位
SpatialReference sr4326 = SpatialReference.create(SpatialReference.WKID_WGS84);
Point p = (Point)GeometryEngine.project(loc, sr4326, map.getSpatialReference()); //转为地图坐标
Graphic g = new Graphic(p, picSymbol);
int id = graphicsLayer.addGraphic(g);
graphicsLayer. updateGraphic(id, g);
setContentView(map);
GraphicsLayer graphicsLayer = new GraphicsLayer();
map.addLayer(graphicsLayer);
算不出来,哈,贴来看看?Drawable drawable = getResources().getDrawable(R.drawable.arrow);
PictureMarkerSymbol picSymbol = new PictureMarkerSymbol(drawable);
Point loc= new Point(1.4191862462692365E7,5183685.4328131145); //获取的定位
SpatialReference sr4326 = SpatialReference.create(SpatialReference.WKID_WGS84);
Point p = (Point)GeometryEngine.project(loc, sr4326, map.getSpatialReference()); //转为地图坐标
Graphic g = new Graphic(p, picSymbol);
int id = graphicsLayer.addGraphic(g);
graphicsLayer. updateGraphic(id, g);
setContentView(map);
GraphicsLayer graphicsLayer = new GraphicsLayer();
map.addLayer(graphicsLayer);这些是写在按钮点击事件里面的,写在oncreate里面就好使
算不出来,哈,贴来看看?
报的错误是failed to generate sequences foe graphic
这个不是GPS抓到的经纬度吧? (似乎是arcgis的投影坐标系)
那就不是WKID_WGS84 格式,所以转换后这个点就不知道跑到那里去了...
我猜:
onCreate()中能显示是因为此时map还未加载好,所以map.getSpatialReference() 也得不到什么值,所以反而能显示.
onClick()时地图加载好了,map.getSpatialReference() 也有值了,结果转换就不对了为了证实猜测,你试试 把1.4191862462692365E7,5183685.4328131145 换成经纬度
估计会变成onCreate() 不能显示,
而 onClick()中能显示 : )