GeoPoint p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
OverlayItem item = new OverlayItem(p, "", "");
item.setMarker(getResources().getDrawable(id));

解决方案 »

  1.   

    百度地图:GeoPoint point = new GeoPoint(
    (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);
      

  2.   

    我用的是arcgis的地图,怎么做啊?
      

  3.   

    arcgis大概如下:
    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);
      

  4.   

    大神,我再oncreat中写会显示,但是将他放在一个方法里,通过按钮点击的话,就不会实现,因为什么啊?
      

  5.   


    我再oncreat中写会显示,但是将他放在一个方法里,通过按钮点击的话,就不会实现,因为什么啊?算不出来,哈,贴来看看?
      

  6.   


    算不出来,哈,贴来看看?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);
      

  7.   


    算不出来,哈,贴来看看?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里面就好使
      

  8.   


    算不出来,哈,贴来看看?
    报的错误是failed to generate sequences foe graphic
      

  9.   

    Point  loc= new Point(1.4191862462692365E7,5183685.4328131145);
    这个不是GPS抓到的经纬度吧?  (似乎是arcgis的投影坐标系)
    那就不是WKID_WGS84 格式,所以转换后这个点就不知道跑到那里去了...
    我猜:
    onCreate()中能显示是因为此时map还未加载好,所以map.getSpatialReference() 也得不到什么值,所以反而能显示.
    onClick()时地图加载好了,map.getSpatialReference() 也有值了,结果转换就不对了为了证实猜测,你试试 把1.4191862462692365E7,5183685.4328131145 换成经纬度  
    估计会变成onCreate() 不能显示,
    而 onClick()中能显示 : )