Java 类com.baidu.mapapi.map.OverlayItem 实例源码

项目:TAG    文件:BaiduMapActivity.java   
private void showMap(double latitude, double longtitude, String address) {
    sendButton.setVisibility(View.GONE);

    GeoPoint point1 = new GeoPoint((int) (latitude * 1e6), (int) (longtitude * 1e6));
    point1 = CoordinateConvert.fromGcjToBaidu(point1);
    mMapController.setCenter(point1);
    Drawable marker = this.getResources().getDrawable(R.drawable.icon_marka);
    // 为maker定义位置和边界
    marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
    mAddrOverlay = new ItemizedOverlay<OverlayItem>(marker, mMapView);
    GeoPoint point = new GeoPoint((int) (latitude * 1e6), (int) (longtitude * 1e6));
    point = CoordinateConvert.fromGcjToBaidu(point);
    OverlayItem addrItem = new OverlayItem(point, "", address);
    mAddrOverlay.addItem(addrItem);
    mMapView.getOverlays().add(mAddrOverlay);
    mMapView.refresh();
}
项目:ACCAndroid    文件:BaiduMapManager.java   
public void animateTo(GeoPoint geoPoint, Drawable drawable) {
    // LogUtil.systemOut(geoPoint);
    if (geoPoint == null || drawable == null) {
        return;
    }
    // System.out.println("x:" + geoPoint.getLatitudeE6() + "y:"
    // + geoPoint.getLongitudeE6());
    this.myOverlay.removeAll();
    if (this.isUsePopup) {
        this.popupOverlay.hidePop();
    }
    OverlayItem overlayItem = new OverlayItem(geoPoint, null, null);
    overlayItem.setMarker(drawable != null ? drawable
            : this.defaultDrawable);
    this.myOverlay.addItem(overlayItem);
    // this.geoPoints.add(geoPoint);
    this.mapController.setZoom(100);
    this.animateTo(geoPoint);
    // LogUtil.systemOut("++++++--------");
    this.mMapView.refresh();
}
项目:FunWeibo    文件:BaiduMapActivity.java   
@Override
public void handleMessage(Message msg) {
    switch(msg.what) {
        case MSG_OPEN_POP_WINDOW: {
            if(msg.obj instanceof OverlayItem) {
                OverlayItem item = (OverlayItem)msg.obj;
                mPopContent.setText(item.getTitle());
                mPopWindow.showPopup(mPopContent, item.getPoint(), POP_OFFSET_PX);
            }
            break;
        }

        default:
            super.handleMessage(msg);
            break;
    }
}
项目:FunWeibo    文件:BaiduMapActivity.java   
/**
 * 把一个标注点添加到地图上
 */
private void addMarker(double lat, double lon, String title, String address) {
    //标记点图像
    Drawable mark = getResources().getDrawable(R.drawable.icon_gcoding);
    //创建Overlay
    MyOverlay overlay = new MyOverlay(mark, mMapView);

    //将Overlay添加到地图上
    mMapView.getOverlays().clear();
    mMapView.getOverlays().add(overlay);

    //添加标注点
    GeoPoint p = CoordinateConvert.fromGcjToBaidu(new GeoPos(lat, lon));
    OverlayItem item = new OverlayItem(p, title, address);
    overlay.addItem(item);
    sendMessage(MSG_OPEN_POP_WINDOW, 0, 0, item);

    //刷新地图
    mMapView.refresh();
}
项目:itmarry    文件:CloudOverlay.java   
public void setData(List<CloudPoiInfo> lbsPoints) {
    if (lbsPoints != null) {
        mLbsPoints = lbsPoints;
    }
    for (CloudPoiInfo rec : mLbsPoints) {
        GeoPoint pt = new GeoPoint((int) (rec.latitude * 1e6),
                (int) (rec.longitude * 1e6));
        OverlayItem item = new OverlayItem(pt, rec.title, rec.address);
        Drawable marker1 = this.mContext.getResources().getDrawable(
                R.drawable.icon_school);
        item.setMarker(marker1);
        addItem(item);
    }
}
项目:calltaxi    文件:MapActivity.java   
@Override
public void run() {
    Looper.prepare();
    while(true) {
        try {
            Thread.sleep(2000);
            itemOverlay.removeAll();

            String url = prefix + "getDriver.php";
            String ret = new HttpFunc().execute(url);
            JSONArray json = new JSONArray(ret);

            double last = 0; 
            for(int i = 0 ;i < json.length(); i++) { 
                double value = json.getDouble(i);
                if(0 == i % 2)
                    last = value;
                else {
                    GeoPoint p1 = new GeoPoint((int) (last * 1E6), (int) (value * 1E6));  
                    OverlayItem item = new OverlayItem(p1,"","");  
                    itemOverlay.addItem(item);
                }
            }
               mMapView.refresh();  
        } 
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:calltaxi    文件:MapActivity.java   
@Override
public void run() {
    Looper.prepare();
    while(true) {
        try {
            Thread.sleep(2000);
            itemOverlay.removeAll();

            String url = prefix + "getUser.php";
            String ret = new HttpFunc().execute(url);
            JSONArray json = new JSONArray(ret);

            double last = 0, value; 
            for(int i = 0 ;i < json.length(); i++) { 
                if(2 == i % 3) {
                    log_id[i/3] = json.getInt(i);
                    continue;
                }
                value = json.getDouble(i);
                if(0 == i % 3)
                    lati[i/3] = value;
                else if(1 == i % 3) {
                    Long[i/3] = value;
                    GeoPoint p1 = new GeoPoint((int) (lati[i/3] * 1E6), (int) (Long[i/3] * 1E6));  
                    OverlayItem item = new OverlayItem(p1,"","");  
                    itemOverlay.addItem(item);
                }
            }
               mMapView.refresh();  
        } 
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:p1-android    文件:VenueActivity.java   
public void addVenueLocations(List<BDLocation> locationList) {
    ItemizedOverlay<OverlayItem> locationOverlay = new ItemizedOverlay<OverlayItem>(
            getResources().getDrawable(R.drawable.ic_checkbox_selected),
            mMapView);
    mMapView.getOverlays().add(locationOverlay);
    GeoPoint geoPoint = null;
    for (BDLocation location : locationList) {
        geoPoint = Utils.BDToGeoPoint(location);
        locationOverlay.addItem(new OverlayItem(geoPoint, "A", "A"));
    }

}
项目:FunWeibo    文件:BaiduMapActivity.java   
protected boolean onTap(int index) {
    //在此处理item点击事件
    OverlayItem item = getItem(index);      //获取对应的OverlayItem
    if(item != null) {
        Message msg = mHandler.obtainMessage(MSG_OPEN_POP_WINDOW, item);
        mMapView.getController().animateTo(item.getPoint(), msg);
    }
    return true;
}
项目:TAG    文件:BaiduMapActivity.java   
private void showMapWithLocationClient() {
    progressDialog = new ProgressDialog(this);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setMessage("正在确定你的位置...");

    progressDialog.setOnCancelListener(new OnCancelListener() {

        public void onCancel(DialogInterface arg0) {
            if (progressDialog.isShowing()) {
                progressDialog.dismiss();
            }
            Log.d("map cancel retrieve location");
            finish();
        }
    });

    progressDialog.show();

    mLocClient = new LocationClient(this);
    mLocClient.registerLocationListener(myListener);

    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true);// 打开gps
    // option.setCoorType("bd09ll"); //设置坐标类型
    // Johnson change to use gcj02 coordination. chinese national standard
    // so need to conver to bd09 everytime when draw on baidu map
    option.setCoorType("gcj02");
    option.setScanSpan(30000);
    option.setAddrType("all");
    mLocClient.setLocOption(option);

    Drawable marker = this.getResources().getDrawable(R.drawable.icon_marka);
    // 为maker定义位置和边界
    marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
    mAddrOverlay = new ItemizedOverlay<OverlayItem>(marker, mMapView);
    mMapView.getOverlays().add(mAddrOverlay);

    mMapListener = new MKMapViewListener() {

        @Override
        public void onMapMoveFinish() {
            // TODO Auto-generated method stub
        }

        @Override
        public void onClickMapPoi(MapPoi mapPoiInfo) {
            // TODO Auto-generated method stub
            String title = "";
            if (mapPoiInfo != null) {
                title = mapPoiInfo.strText;
                Toast.makeText(BaiduMapActivity.this, title, Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onGetCurrentMap(Bitmap b) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onMapAnimationFinish() {
        }
    };
    mMapView.regMapViewListener(mBMapManager, mMapListener);

    if (lastLocation != null) {
        GeoPoint point1 = new GeoPoint((int) (lastLocation.getLatitude() * 1e6), (int) (lastLocation.getLongitude() * 1e6));
        point1 = CoordinateConvert.fromGcjToBaidu(point1);
        mMapController.setCenter(point1);
    }
    mMapView.refresh();
    mMapView.invalidate();
}
项目:TAG    文件:BaiduMapActivity.java   
@Override
public void onReceiveLocation(BDLocation location) {
    if (location == null) {
        return;
    }
    Log.d("map On location change received:" + location);
    Log.d("map addr:" + location.getAddrStr());
    sendButton.setEnabled(true);
    if (progressDialog != null) {
        progressDialog.dismiss();
    }

    if (lastLocation != null) {
        if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) {
            Log.d("map same location, skip refresh");
            // mMapView.refresh(); //need this refresh?
            return;
        }
    }

    lastLocation = location;

    GeoPoint gcj02Point = new GeoPoint((int) (location.getLatitude() * 1e6), (int) (location.getLongitude() * 1e6));
    EMLog.d(TAG, "GCJ-02 loc:" + gcj02Point);
    GeoPoint point = CoordinateConvert.fromGcjToBaidu(gcj02Point);
    EMLog.d(TAG, "converted BD-09 loc:" + point);

    // GeoPoint p1 = gcjToBaidu(location.getLatitude(),
    // location.getLongitude());
    // System.err.println("johnson change to baidu:" + p1);
    // GeoPoint p2 = baiduToGcj(location.getLatitude(),
    // location.getLongitude());
    // System.err.println("johnson change to gcj:" + p2);

    OverlayItem addrItem = new OverlayItem(point, "title", location.getAddrStr());
    mAddrOverlay.removeAll();
    mAddrOverlay.addItem(addrItem);
    mMapView.getController().setZoom(17);
    mMapView.refresh();
    mMapController.animateTo(point);
}
项目:ACCAndroid    文件:BaiduMapManager.java   
public void updateMapView(List<BaiduMapData> baiduMapDatas) {
    this.myOverlay.removeAll();
    if (this.isUsePopup) {
        this.popupOverlay.hidePop();
    }
    if (!ListUtil.isEmpty(baiduMapDatas)) {
        // this.tasks = new ArrayList<Task>();
        this.geoPoints = new ArrayList<GeoPoint>();
        for (BaiduMapData baiduMapData : baiduMapDatas) {
            MGeoPoint mGeoPoint = baiduMapData.getmGeoPoint();
            if (baiduMapData.getmGeoPoint() != null) {
                GeoPoint geoPoint = new GeoPoint(
                        (int) (mGeoPoint.getLatitude() * 1E6),
                        (int) (mGeoPoint.getLongitude() * 1E6));
                // LogUtil.systemOut(geoPoint);
                OverlayItem overlayItem = new OverlayItem(geoPoint, null,
                        null);
                overlayItem
                        .setMarker(baiduMapData.getDrawable() != null ? baiduMapData
                                .getDrawable() : this.defaultDrawable);
                myOverlay.addItem(overlayItem);
                // this.tasks.add(task);
                this.geoPoints.add(geoPoint);
            }
        }
        // /**
        // * 鍑嗗overlay 鏁版嵁
        // */
        // GeoPoint p1 = new GeoPoint((int) (mLat1 * 1E6), (int) (mLon1 *
        // 1E6));
        // OverlayItem item1 = new OverlayItem(p1, "瑕嗙洊鐗�1", "");
        // /**
        // * 璁剧疆overlay鍥炬爣锛屽涓嶈缃紝鍒欎娇鐢ㄥ垱寤篒temizedOverlay鏃剁殑榛樿鍥炬爣.
        // */
        // item1.setMarker(getResources().getDrawable(R.drawable.icon_marka));
        //
        // GeoPoint p2 = new GeoPoint((int) (mLat2 * 1E6), (int) (mLon2 *
        // 1E6));
        // OverlayItem item2 = new OverlayItem(p2, "瑕嗙洊鐗�2", "");
        // item2.setMarker(getResources().getDrawable(R.drawable.icon_marka));
        //
        // GeoPoint p3 = new GeoPoint((int) (mLat3 * 1E6), (int) (mLon3 *
        // 1E6));
        // OverlayItem item3 = new OverlayItem(p3, "瑕嗙洊鐗�3", "");
        // item3.setMarker(getResources().getDrawable(R.drawable.icon_marka));
        //
        // GeoPoint p4 = new GeoPoint((int) (mLat4 * 1E6), (int) (mLon4 *
        // 1E6));
        // OverlayItem item4 = new OverlayItem(p4, "瑕嗙洊鐗�4", "");
        // item4.setMarker(getResources().getDrawable(R.drawable.icon_gcoding));
        // /**
        // * 灏唅tem 娣诲姞鍒皁verlay涓� 娉ㄦ剰锛� 鍚屼竴涓猧tme鍙兘add涓�娆�
        // */
        // myOverlay.addItem(item1);
        // myOverlay.addItem(item2);
        // myOverlay.addItem(item3);
        // myOverlay.addItem(item4);
        this.animateToBestZoomAndCenter();
    }

    this.mMapView.refresh();
    // this.mapController.animateTo(this.geoPoints.get(0));
}