android 高德地图自定义图标加图标之间的连线

 效果:

 

 requestQueue = Volley.newRequestQueue(context);
@Override
public void getRouteEquipment(final AMap aMap, String signature, String echostr, String timestamp, final Context context, final IscView iscView, String route, final FrameLayout fl_other) {
   
    final MyStringRequest stringrequest = new MyStringRequest(Request.Method.GET, "http://***********?signature=" + signature + "&echostr=" + echostr + "×tamp=" + timestamp + "&method=getElements&filter=Route&route=" + route, new Response.Listener() {
        @Override
        public void onResponse(String s) {
            try {
                android.util.Log.d("getRouteEquipment", s);
                JSONArray jsonArray = new JSONArray(s);
                List list_routeline = new ArrayList();
                List latLngs = new ArrayList();
                if (jsonArray.length() > 0) {
                    aMap.clear();
                    fl_other.setVisibility(View.GONE);
                    for (int i = 0; i < jsonArray.length(); i++) {
                        JSONObject jsonObject = (JSONObject) jsonArray.get(i);
                        getEquipmentIcon(jsonObject.getString("iconName"), jsonObject.getString("status"), jsonObject, iscView, true, (i + 1) + "",null);
                        latLngs.add(new LatLng(Double.parseDouble(jsonObject.getString("latitude")), Double.parseDouble(jsonObject.getString("longitude"))));
                        LatLng latLng = new LatLng(Double.parseDouble(jsonObject.getString("latitude")), Double.parseDouble(jsonObject.getString("longitude")));
                        aMap.addPolyline(new PolylineOptions().
                                addAll(latLngs).width(11).color(Color.parseColor("#6584f4")));
                    }
                   /* aMap.addPolygon(new PolygonOptions().addAll(latLngs).strokeWidth(15) // 多边形的边框
                            .strokeColor(Color.parseColor("#f59208")) // 边框颜色
                            .fillColor(Color.parseColor("#FFFFFF")));*/

                } else {
                    Toast.makeText(context, "没有数据", Toast.LENGTH_SHORT).show();
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            android.util.Log.d("initVolley", volleyError.getMessage() + "");
        }
    });
    requestQueue.add(stringrequest);
}

 

//自定会图片和自定义marker布局

@Override
public void geticonName(int iconId, String latitude, String longitude, String categoryCode,Boolean textShow,String text) {
    if(textShow){
   //自定义marker布局和图片
    aMap.addMarker(new MarkerOptions()
            .snippet(categoryCode)
            .draggable(false)
         //   .icon(BitmapDescriptorFactory.fromResource(iconIgetMarkerViewd))
            .icon(BitmapDescriptorFactory.fromBitmap(getMarkerView(iconId,text)))
            .position(new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude))));
    }else{
          //自定义marker图片
        Log.d("iconIds",""+categoryCode);
       // Bitmap bm=getMarkerViewone(iconId);
       // if(bm != null && !"".equals(bm)) {
            aMap.addMarker(new MarkerOptions()
                    .snippet(categoryCode)
                    .draggable(false)
                  //  .icon(BitmapDescriptorFactory.fromBitmap(bm))
                    .icon(BitmapDescriptorFactory.fromResource(iconId))
                    .position(new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude))));
        }
 //   }

}

 

//自定义布局转换为bitmap
  Bitmap getMarkerView(int iconId,String text){
    View view = this.getLayoutInflater().inflate(R.layout.gaode_marker_item,
            null);
    ImageView im_marker = (ImageView) view.findViewById(R.id.im_marker);
    TextView tv_marker = (TextView) view.findViewById(R.id.tv_marker);
    im_marker.setImageResource(iconId);
    tv_marker.setText(text);
    Bitmap bitmap = convertViewToBitmap(view);
    return bitmap;
}
  Bitmap getMarkerViewone(int iconId){
      View view = this.getLayoutInflater().inflate(R.layout.gaode_marker_item_one,
              null);
      ImageView im_marker = (ImageView) view.findViewById(R.id.im_marker);
      im_marker.setImageResource(iconId);
      Bitmap bitmap = convertViewToBitmap(view);
      return bitmap;
  }

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(android 高德地图自定义图标加图标之间的连线)