Пример #1
0
 void initView() {
   toolbar = (Toolbar) findViewById(R.id.toolbar);
   mapView = (MapView) findViewById(R.id.mapview);
   fab = (FloatingActionButton) findViewById(R.id.fab);
   bd = BitmapDescriptorFactory.fromResource(R.drawable.icon_gcoding);
   info = BitmapDescriptorFactory.fromResource(R.drawable.popup);
   drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
 }
Пример #2
0
 public List<BitmapDescriptor> getCustomTextureList() {
   ArrayList<BitmapDescriptor> list = new ArrayList<BitmapDescriptor>();
   list.add(BitmapDescriptorFactory.fromAsset("Icon_road_blue_arrow.png"));
   list.add(BitmapDescriptorFactory.fromAsset("Icon_road_green_arrow.png"));
   list.add(BitmapDescriptorFactory.fromAsset("Icon_road_yellow_arrow.png"));
   list.add(BitmapDescriptorFactory.fromAsset("Icon_road_red_arrow.png"));
   list.add(BitmapDescriptorFactory.fromAsset("Icon_road_nofocus.png"));
   return list;
 }
Пример #3
0
  public void initOverlay() {
    // add marker overlay
    addOverlay(39.963175, 116.400244, R.drawable.icon_marka, 9);
    addOverlay(39.942821, 116.369199, R.drawable.icon_markb, 5);
    MarkerOptions ooC = (MarkerOptions) addOverlay(39.939723, 116.425541, R.drawable.icon_markc, 7);
    MarkerOptions ooD = (MarkerOptions) addOverlay(39.906965, 116.401394, R.drawable.icon_markd, 0);
    ooC.perspective(false).anchor(0.5f, 0.5f).rotate(30);
    ooD.period(10);

    //		ArrayList<BitmapDescriptor> giflist = new ArrayList<BitmapDescriptor>();
    //		giflist.add(bdA);
    //		giflist.add(bdB);
    //		giflist.add(bdC);

    BitmapDescriptor bd = BitmapDescriptorFactory.fromResource(R.drawable.icon_gcoding);
    mBitmapList.add(bd);
    // add ground overlay
    LatLng southwest = new LatLng(39.92235, 116.380338);
    LatLng northeast = new LatLng(39.947246, 116.414977);
    LatLngBounds bounds = new LatLngBounds.Builder().include(northeast).include(southwest).build();

    BitmapDescriptor bdGround = BitmapDescriptorFactory.fromResource(R.drawable.ground_overlay);

    mBitmapList.add(bdGround);
    OverlayOptions ooGround =
        new GroundOverlayOptions().positionFromBounds(bounds).image(bdGround).transparency(0.8f);
    mBaiduMap.addOverlay(ooGround);

    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(bounds.getCenter());
    mBaiduMap.setMapStatus(u);

    mBaiduMap.setOnMarkerDragListener(
        new OnMarkerDragListener() {
          public void onMarkerDrag(Marker marker) {}

          public void onMarkerDragEnd(Marker marker) {
            Toast.makeText(
                    OverlayDemo.this,
                    "拖拽结束,新位置:"
                        + marker.getPosition().latitude
                        + ", "
                        + marker.getPosition().longitude,
                    Toast.LENGTH_LONG)
                .show();
          }

          public void onMarkerDragStart(Marker marker) {}
        });
  }
Пример #4
0
 @Override
 public BitmapDescriptor getTerminalMarker() {
   if (useDefaultIcon) {
     return BitmapDescriptorFactory.fromResource(R.drawable.icon_en);
   }
   return null;
 }
  private void initLocation() {

    mLocationMode = com.baidu.mapapi.map.MyLocationConfiguration.LocationMode.NORMAL;
    mLocationClient = new LocationClient(this);
    mLocationListener = new MyLocationListener();
    mLocationClient.registerLocationListener(mLocationListener);

    LocationClientOption option = new LocationClientOption();
    option.setCoorType("bd09ll");
    option.setIsNeedAddress(true);
    option.setOpenGps(true);
    option.setScanSpan(1000);

    mLocationClient.setLocOption(option);
    // 初始化图标
    mIconLocation = BitmapDescriptorFactory.fromResource(R.drawable.navi_map_gps_locked);

    myOrientationListener = new MyOrientationListener(context);

    myOrientationListener.setOnOrientationListener(
        new OnOrientationListener() {

          @Override
          public void onOrientationChanged(float x) {
            mCurrentX = x;
          }
        });
  }
Пример #6
0
  /** 设置当前位置,如果是第一次则动画移动到当前位置 */
  private void setMyLocOnMap() {

    MyLocationData.Builder builder =
        new MyLocationData.Builder()
            .latitude(cLoc.getLatitude())
            .longitude(cLoc.getLongitude())
            .accuracy(cLoc.getRadius())
            .direction(mOrientation);
    baiduMap.setMyLocationData(builder.build());

    if (currentIcon == null) {
      currentIcon = BitmapDescriptorFactory.fromResource(R.mipmap.main_icon_nav);
    }

    baiduMap.setMyLocationConfigeration(
        new MyLocationConfiguration(
            MyLocationConfiguration.LocationMode.NORMAL, true, currentIcon));

    if (isFirst && type == 1) {
      isFirst = false;
      // 设置默认比例尺15(20-3)
      MapStatusUpdate update =
          MapStatusUpdateFactory.newLatLngZoom(
              new LatLng(cLoc.getLatitude(), cLoc.getLongitude()), baiduMap.getMapStatus().zoom);

      baiduMap.animateMapStatus(update);
    }
  }
Пример #7
0
  private void initLocation() {
    // TODO Auto-generated method stub
    client = new LocationClient(this);
    locationlistener = new Mylocation();
    client.registerLocationListener(locationlistener);
    // 设置location的一些参数
    LocationClientOption option = new LocationClientOption();
    option.setCoorType("bd09ll");
    option.setIsNeedAddress(true); // 获得当前的地址
    option.setOpenGps(true);
    option.setScanSpan(1000);
    client.setLocOption(option); // 设置完成上述功能
    // 初始化图标
    mylocationbitmap = BitmapDescriptorFactory.fromResource(R.drawable.arrow);
    // 初始化 方向传感器
    myorientaion = new MyOrientation(this);
    myorientaion.setChanged(
        new OrientainChanged() {

          @Override
          public void Onchanged(float x) {
            // TODO Auto-generated method stub
            CurrentX = x;
          }
        });
  }
Пример #8
0
 private void locateMyLocation(UserShakeData userShakeData) {
   LatLng cenpt = new LatLng(userShakeData.getLatitude(), userShakeData.getLongitude());
   locatePotin(cenpt);
   BitmapDescriptor markIcon = BitmapDescriptorFactory.fromResource(R.drawable.lj_map_my_location);
   OverlayOptions option = new MarkerOptions().position(cenpt).icon(markIcon);
   myContext.baiduMap.addOverlay(option);
 }
Пример #9
0
  /**
   * 把一个坐标点显示在地图上面.
   *
   * @param mMapView
   * @param point
   * @param image 默认图片资源id
   */
  public void showOnePoint(final BaiduMap mBaiduMap, final MyPoint point, int image) {
    mBaiduMap.clear();

    LatLng llA = new LatLng(point.getLat(), point.getLng());
    BitmapDescriptor bdA = BitmapDescriptorFactory.fromResource(R.drawable.icon_geo);

    OverlayOptions ooA = new MarkerOptions().position(llA).icon(bdA).zIndex(9).draggable(true);
    final Marker mMarkerA = (Marker) (mBaiduMap.addOverlay(ooA));

    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(llA);
    mBaiduMap.setMapStatus(u);
    mBaiduMap.setOnMarkerClickListener(
        new OnMarkerClickListener() {
          public boolean onMarkerClick(final Marker marker) {
            Button button = new Button(context);
            button.setBackgroundResource(R.drawable.popup);
            OnInfoWindowClickListener listener = null;
            if (marker == mMarkerA) {
              button.setText(point.getName());
              listener =
                  new OnInfoWindowClickListener() {
                    public void onInfoWindowClick() {
                      mBaiduMap.hideInfoWindow();
                    }
                  };
              LatLng ll = marker.getPosition();
              InfoWindow mInfoWindow =
                  new InfoWindow(BitmapDescriptorFactory.fromView(button), ll, -47, listener);
              mBaiduMap.showInfoWindow(mInfoWindow);
            }
            return true;
          }
        });
  }
Пример #10
0
 private MarkerOptions addOverlay(double lat, double lng, int resID, int zIndex) {
   LatLng llA = new LatLng(lat, lng);
   BitmapDescriptor bdA = BitmapDescriptorFactory.fromResource(resID);
   mBitmapList.add(bdA);
   MarkerOptions ooA = new MarkerOptions().position(llA).icon(bdA).zIndex(zIndex).draggable(true);
   mMarkerList.add((Marker) mBaiduMap.addOverlay(ooA));
   return ooA;
 }
Пример #11
0
 private void drawAreadyLin(List<LatLng> agoList) {
   BitmapDescriptor custom1 = BitmapDescriptorFactory.fromResource(R.drawable.icon_road_red_arrow);
   OverlayOptions ooPolyline =
       new PolylineOptions().width(15).color(0xAAFF0000).points(agoList).customTexture(custom1);
   // .textureIndex(index);
   // 添加到地图
   mBaiduMap.addOverlay(ooPolyline);
 }
Пример #12
0
 public static BitmapDescriptor getBitmapFromView(View view) {
   view.destroyDrawingCache();
   view.measure(
       View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
       View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
   view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
   view.setDrawingCacheEnabled(true);
   Bitmap bitmap = view.getDrawingCache(true);
   BitmapDescriptor bd = BitmapDescriptorFactory.fromBitmap(bitmap);
   return bd;
 }
Пример #13
0
  private void addlayout(String lat, String lng, String name, String adress, String phone) {
    LatLng ll =
        new LatLng(Double.parseDouble("" + lat) - 0.00005, Double.parseDouble("" + lng) - 0.00005);
    View view2 = LayoutInflater.from(mContext).inflate(R.layout.over_map, null);
    ((TextView) view2.findViewById(R.id.hospital_name)).setText("医院:" + name);
    ((TextView) view2.findViewById(R.id.adress)).setText("地址:" + adress);
    ((TextView) view2.findViewById(R.id.phone))
        .setText("距离:" + Float.parseFloat(phone) / 1000 + "km");
    BitmapDescriptor bdA = BitmapDescriptorFactory.fromBitmap(textTobimap(view2));
    OverlayOptions ooA = new MarkerOptions().position(ll).icon(bdA).zIndex(9).draggable(true);
    mBaiduMap.addOverlay(ooA);

    LatLng point = new LatLng(Double.parseDouble("" + lat), Double.parseDouble("" + lng));
    // 构建Marker图标
    BitmapDescriptor bitmap = BitmapDescriptorFactory.fromResource(R.drawable.icon_marka);
    // 构建MarkerOption,用于在地图上添加Marker
    OverlayOptions option = new MarkerOptions().position(point).icon(bitmap);
    // 在地图上添加Marker,并显示
    mBaiduMap.addOverlay(option);
  }
 /**
  * er for a Cluster is added to the map. Called before the mark The default implementation draws a
  * circle with a rough count of the number of items.
  */
 protected void onBeforeClusterRendered(Cluster<T> cluster, MarkerOptions markerOptions) {
   int bucket = getBucket(cluster);
   BitmapDescriptor descriptor = mIcons.get(bucket);
   if (descriptor == null) {
     mColoredCircleBackground.getPaint().setColor(getColor(bucket));
     descriptor =
         BitmapDescriptorFactory.fromBitmap(mIconGenerator.makeIcon(getClusterText(bucket)));
     mIcons.put(bucket, descriptor);
   }
   // TODO: consider adding anchor(.5, .5) (Individual markers will overlap more often)
   markerOptions.icon(descriptor);
 }
Пример #15
0
  private void addMakerToMap(LatLng latLng) {
    // 隐藏食指点击动画
    // imageHandClick.setVisibility(View.GONE);

    baiduMap.clear();
    BitmapDescriptor bitmapDescriptor =
        BitmapDescriptorFactory.fromResource(R.drawable.ui_marker_select);

    OverlayOptions ooA =
        new MarkerOptions().position(latLng).icon(bitmapDescriptor).zIndex(9).draggable(true);
    baiduMap.addOverlay(ooA);
  }
Пример #16
0
 private void drawLines(double oldLat, double newLat, double oldLng, double newLng) {
   // TODO Auto-generated method stub
   // 绘制纹理图
   BitmapDescriptor custom1 = BitmapDescriptorFactory.fromResource(R.drawable.icon_road_red_arrow);
   Log.e("old", oldLat + "<==" + oldLng + "--" + newLat + "<==" + newLng);
   LatLng pt1 = new LatLng(oldLat, oldLng);
   LatLng pt2 = new LatLng(newLat, newLng);
   points.add(pt1); // 点元素
   points.add(pt2); // 点元素
   OverlayOptions ooPolyline =
       new PolylineOptions().width(15).color(0xAAFF0000).points(points).customTexture(custom1);
   mBaiduMap.addOverlay(ooPolyline);
 }
Пример #17
0
  public void setMarker(ArrayList<Station> list) {
    View view = LayoutInflater.from(mContext).inflate(R.layout.marker, null);
    final TextView tv = (TextView) view.findViewById(R.id.tv_marker);
    for (int i = 0; i < list.size(); i++) {
      Station s = list.get(i);
      tv.setText((i + 1) + "");
      if (i == 0) {
        tv.setBackgroundResource(R.mipmap.icon_focus_mark);
      } else {
        tv.setBackgroundResource(R.mipmap.icon_mark);
      }
      BitmapDescriptor bitmap = BitmapDescriptorFactory.fromView(tv);
      LatLng latLng = new LatLng(s.getLat(), s.getLon());
      Bundle b = new Bundle();
      b.putParcelable("s", list.get(i));
      OverlayOptions oo =
          new MarkerOptions().position(latLng).icon(bitmap).title((i + 1) + "").extraInfo(b);
      if (i == 0) {
        lastMarker = (Marker) mBaiduMap.addOverlay(oo);
        mStation = s;
        showLayoutInfo((i + 1) + "", mStation);
      } else {
        mBaiduMap.addOverlay(oo);
      }
    }

    mBaiduMap.setOnMarkerClickListener(
        new BaiduMap.OnMarkerClickListener() {

          @Override
          public boolean onMarkerClick(Marker marker) {
            // TODO Auto-generated method stub
            if (lastMarker != null) {
              tv.setText(lastMarker.getTitle());
              tv.setBackgroundResource(R.mipmap.icon_mark);
              BitmapDescriptor bitmap = BitmapDescriptorFactory.fromView(tv);
              lastMarker.setIcon(bitmap);
            }
            lastMarker = marker;
            String position = marker.getTitle();
            tv.setText(position);
            tv.setBackgroundResource(R.mipmap.icon_focus_mark);
            BitmapDescriptor bitmap = BitmapDescriptorFactory.fromView(tv);
            marker.setIcon(bitmap);
            mStation = marker.getExtraInfo().getParcelable("s");
            showLayoutInfo(position, mStation);
            return false;
          }
        });
  }
Пример #18
0
    private void setMarkerIcon(Marker marker, boolean focused) {

      if (marker == null) return;

      int pos = marker.getZIndex();

      BitmapDescriptor descriptor =
          BitmapDescriptorFactory.fromResource(
              focused
                  ? marker_focus_icon_ids[pos % marker_focus_icon_ids.length]
                  : marker_icon_ids[pos % marker_icon_ids.length]);

      marker.setIcon(descriptor);
    }
Пример #19
0
 @Override
 public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) {
   if (reverseGeoCodeResult == null
       || reverseGeoCodeResult.error != SearchResult.ERRORNO.NO_ERROR) {
     Toast.makeText(NewMapActivity.this, "抱歉,未能找到结果", Toast.LENGTH_LONG).show();
     return;
   }
   mBaiduMap.clear();
   mBaiduMap.addOverlay(
       new MarkerOptions()
           .position(reverseGeoCodeResult.getLocation())
           .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_marka)));
   mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(reverseGeoCodeResult.getLocation()));
   Toast.makeText(NewMapActivity.this, reverseGeoCodeResult.getAddress(), Toast.LENGTH_LONG)
       .show();
 }
Пример #20
0
 private void locateOtherLocation(UserShakeData userShakeData, int index) {
   LatLng cenpt = new LatLng(userShakeData.getLatitude(), userShakeData.getLongitude());
   String sex = userShakeData.getSex();
   TextView view = new TextView(myContext);
   view.setTextColor(Color.WHITE);
   view.setTextSize(15);
   view.setGravity(Gravity.CENTER_HORIZONTAL);
   view.setText(String.valueOf(index + 1));
   if (sex.equals("female")) view.setBackgroundResource(R.drawable.lj_map_female_location);
   else view.setBackgroundResource(R.drawable.lj_map_male_location);
   BitmapDescriptor markIcon = BitmapDescriptorFactory.fromBitmap(getBitmapFromView(view));
   OverlayOptions option = new MarkerOptions().position(cenpt).icon(markIcon);
   Marker marker = (Marker) myContext.baiduMap.addOverlay(option);
   Bundle bundle = new Bundle();
   bundle.putSerializable("index", index);
   marker.setExtraInfo(bundle);
 }
Пример #21
0
 private void showMap(double latitude, double longtitude, String address) {
   // sendButton.setVisibility(View.GONE);
   LatLng llA = new LatLng(latitude, longtitude);
   CoordinateConverter converter = new CoordinateConverter();
   converter.coord(llA);
   converter.from(CoordinateConverter.CoordType.COMMON);
   LatLng convertLatLng = converter.convert();
   OverlayOptions ooA =
       new MarkerOptions()
           .position(convertLatLng)
           .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_marka))
           .zIndex(4)
           .draggable(true);
   mBaiduMap.addOverlay(ooA);
   MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
   mBaiduMap.animateMapStatus(u);
 }
Пример #22
0
 void loadMarker() {
   for (BranchInfo item : mData) {
     if (item.getLat() == 0 || item.getLng() == 0) continue;
     LatLng latLng = new LatLng(item.getLat(), item.getLng());
     Marker marker =
         (Marker)
             mBaiduMap.addOverlay(
                 new MarkerOptions()
                     .position(latLng)
                     .icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_map_marker)));
     Bundle bundle = new Bundle();
     bundle.putSerializable("info", item);
     marker.setExtraInfo(bundle);
     // 将地图移到到最后一个经纬度位置
     MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(latLng);
     mBaiduMap.setMapStatus(u);
   }
   mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLng(mMyLocation));
 }
Пример #23
0
  /**
   * 把点增加到图上面
   *
   * @param mMapView
   * @param list 点的信息
   * @param image 默认图片资源id
   */
  public void addPt(final BaiduMap mBaiduMap, final List<MyPoint> list, int image) {

    mBaiduMap.clear();
    BitmapDescriptor bdA = BitmapDescriptorFactory.fromResource(R.drawable.icon_geo);
    final List<Marker> markerList = new ArrayList<Marker>();
    for (int i = 0; i < list.size(); i++) {
      LatLng llA = new LatLng(list.get(i).getLat(), list.get(i).getLng());
      OverlayOptions ooA = new MarkerOptions().position(llA).icon(bdA).zIndex(9).draggable(true);
      markerList.add((Marker) (mBaiduMap.addOverlay(ooA)));
    }
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(getCenterPointer(list));
    mBaiduMap.setMapStatus(u);
    mBaiduMap.setOnMarkerClickListener(
        new OnMarkerClickListener() {
          public boolean onMarkerClick(final Marker marker) {
            Button button = new Button(context);
            button.setBackgroundResource(R.drawable.popup);
            OnInfoWindowClickListener listener = null;
            for (int i = 0; i < list.size(); i++) {
              if (marker == markerList.get(i)) {
                button.setText(list.get(i).getName());
                break;
              }
            }
            listener =
                new OnInfoWindowClickListener() {
                  public void onInfoWindowClick() {
                    mBaiduMap.hideInfoWindow();
                  }
                };
            LatLng ll = marker.getPosition();
            InfoWindow mInfoWindow =
                new InfoWindow(BitmapDescriptorFactory.fromView(button), ll, -47, listener);
            mBaiduMap.showInfoWindow(mInfoWindow);

            return true;
          }
        });
  }
Пример #24
0
    @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;
      mBaiduMap.clear();
      LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
      CoordinateConverter converter = new CoordinateConverter();
      converter.coord(llA);
      converter.from(CoordinateConverter.CoordType.COMMON);
      LatLng convertLatLng = converter.convert();
      OverlayOptions ooA =
          new MarkerOptions()
              .position(convertLatLng)
              .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_marka))
              .zIndex(4)
              .draggable(true);
      mBaiduMap.addOverlay(ooA);
      MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
      mBaiduMap.animateMapStatus(u);
    }
Пример #25
0
        /**
         * 地图长按事件监听回调函数
         *
         * @param point 长按的地理坐标
         */
        public void onMapLongClick(LatLng point) {
          hasEndpoint = true;
          // 构建Marker图标
          BitmapDescriptor bitmap = BitmapDescriptorFactory.fromResource(R.drawable.icon_marka);
          // 构建MarkerOption,用于在地图上添加Marker
          OverlayOptions option = new MarkerOptions().position(point).icon(bitmap);
          Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
          getSystemService(VIBRATOR_SERVICE);
          // 震动30ms
          vibrator.vibrate(30);
          // 清除Marker
          mBaiduMap.clear();
          // 在地图上添加Marker,并显示
          mBaiduMap.addOverlay(option);
          Toast.makeText(NavigateActivity.this, "设置为终点", Toast.LENGTH_SHORT).show();

          EditText mDest = (EditText) findViewById(R.id.et_destination);
          mDest.setText("经度:" + point.longitude + " 纬度:" + point.latitude);
          destLoc.setLongitude(point.longitude);
          destLoc.setLatitude(point.latitude);
          System.out.println("终点");
          System.out.println("经度:" + destLoc.getLongitude());
          System.out.println("纬度:" + destLoc.getLatitude());
        }
Пример #26
0
  private void addMarker2Map() {

    List<OverlayOptions> optionses = new ArrayList<OverlayOptions>();

    for (int i = 0; i < data.size(); i++) {

      MyPoiInfo info = data.get(i);
      BitmapDescriptor descriptor =
          BitmapDescriptorFactory.fromResource(marker_icon_ids[i % marker_icon_ids.length]);
      OverlayOptions oo =
          new MarkerOptions()
              .position(new LatLng(info.lat, info.lng))
              .icon(descriptor)
              .zIndex(i)
              .title(info.name);
      optionses.add(oo);
    }

    overlayManager = new MarkerOverLayManager(baiduMap, optionses);
    overlayManager.addToMap();
    // add maker click listener
    baiduMap.setOnMarkerClickListener(overlayManager);
    baiduMap.removeMarkerClickListener(drivingRouteOverlay);
  }
Пример #27
0
  private void tipPlace(double lats, double longs) {
    if (i != 0) {
      // Log.e("iii", "i = "+i);
      marker.remove();
    }

    LatLng point = new LatLng(lats, longs);
    MapStatus mMapStatus =
        new MapStatus.Builder().target(point).zoom(CheezhiApplication.getZooms()).build();

    // mMapView.getMap().get

    MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mMapStatus);
    mBaiduMap.setMapStatus(mMapStatusUpdate);
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(point);
    mBaiduMap.animateMapStatus(u);

    BitmapDescriptor bitmap = BitmapDescriptorFactory.fromResource(R.drawable.icon_geo);

    OverlayOptions options =
        new MarkerOptions().position(point).icon(bitmap).zIndex(9).draggable(true);

    marker = (Marker) (mBaiduMap.addOverlay(options));
  }
Пример #28
0
  @Override
  public final List<OverlayOptions> getOverlayOptions() {
    if (mRouteLine == null) {
      return null;
    }

    List<OverlayOptions> overlayOptionses = new ArrayList<OverlayOptions>();
    // step node
    if (mRouteLine.getAllStep() != null && mRouteLine.getAllStep().size() > 0) {

      for (DrivingStep step : mRouteLine.getAllStep()) {
        Bundle b = new Bundle();
        b.putInt("index", mRouteLine.getAllStep().indexOf(step));
        if (step.getEntrance() != null) {
          overlayOptionses.add(
              (new MarkerOptions())
                  .position(step.getEntrance().getLocation())
                  .anchor(0.5f, 0.5f)
                  .zIndex(10)
                  .rotate((360 - step.getDirection()))
                  .extraInfo(b)
                  .icon(BitmapDescriptorFactory.fromAssetWithDpi("Icon_line_node.png")));
        }
        // 最后路段绘制出口点
        if (mRouteLine.getAllStep().indexOf(step) == (mRouteLine.getAllStep().size() - 1)
            && step.getExit() != null) {
          overlayOptionses.add(
              (new MarkerOptions())
                  .position(step.getExit().getLocation())
                  .anchor(0.5f, 0.5f)
                  .zIndex(10)
                  .icon(BitmapDescriptorFactory.fromAssetWithDpi("Icon_line_node.png")));
        }
      }
    }

    if (mRouteLine.getStarting() != null) {
      overlayOptionses.add(
          (new MarkerOptions())
              .position(mRouteLine.getStarting().getLocation())
              .icon(
                  getStartMarker() != null
                      ? getStartMarker()
                      : BitmapDescriptorFactory.fromAssetWithDpi("Icon_start.png"))
              .zIndex(10));
    }
    if (mRouteLine.getTerminal() != null) {
      overlayOptionses.add(
          (new MarkerOptions())
              .position(mRouteLine.getTerminal().getLocation())
              .icon(
                  getTerminalMarker() != null
                      ? getTerminalMarker()
                      : BitmapDescriptorFactory.fromAssetWithDpi("Icon_end.png"))
              .zIndex(10));
    }
    // poly line
    if (mRouteLine.getAllStep() != null && mRouteLine.getAllStep().size() > 0) {

      List<DrivingStep> steps = mRouteLine.getAllStep();
      int stepNum = steps.size();

      List<LatLng> points = new ArrayList<LatLng>();
      ArrayList<Integer> traffics = new ArrayList<Integer>();
      int totalTraffic = 0;
      for (int i = 0; i < stepNum; i++) {
        if (i == stepNum - 1) {
          points.addAll(steps.get(i).getWayPoints());
        } else {
          points.addAll(
              steps.get(i).getWayPoints().subList(0, steps.get(i).getWayPoints().size() - 1));
        }

        totalTraffic += steps.get(i).getWayPoints().size() - 1;
        if (steps.get(i).getTrafficList() != null && steps.get(i).getTrafficList().length > 0) {
          for (int j = 0; j < steps.get(i).getTrafficList().length; j++) {
            traffics.add(steps.get(i).getTrafficList()[j]);
          }
        }
      }

      //            Bundle indexList = new Bundle();
      //            if (traffics.size() > 0) {
      //                int raffic[] = new int[traffics.size()];
      //                int index = 0;
      //                for (Integer tempTraff : traffics) {
      //                    raffic[index] = tempTraff.intValue();
      //                    index++;
      //                }
      //                indexList.putIntArray("indexs", raffic);
      //            }
      boolean isDotLine = false;

      if (traffics != null && traffics.size() > 0) {
        isDotLine = true;
      }
      PolylineOptions option =
          new PolylineOptions()
              .points(points)
              .textureIndex(traffics)
              .width(7)
              .dottedLine(isDotLine)
              .focus(true)
              .color(getLineColor() != 0 ? getLineColor() : Color.argb(178, 0, 78, 255))
              .zIndex(0);
      if (isDotLine) {
        option.customTextureList(getCustomTextureList());
      }
      overlayOptionses.add(option);
    }
    return overlayOptionses;
  }
Пример #29
0
 // 覆盖物初始化
 private void initMapWu() {
   // TODO Auto-generated method stub
   mMarker = BitmapDescriptorFactory.fromResource(R.drawable.dingweitubiao); // 获得定位的图片
 }
 private void initMarker() {
   // TODO Auto-generated method stub
   mMarker = BitmapDescriptorFactory.fromResource(R.drawable.maker);
   mMarkerLy = (RelativeLayout) findViewById(R.id.id_maker_ly);
 }