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 + "&timestamp=" + timestamp + "&method=getElements&filter=Route&route=" + route, new Response.Listener<String>() {
@Override
public void onResponse(String s) {
try {
android.util.Log.d("getRouteEquipment", s);
JSONArray jsonArray = new JSONArray(s);
List<RouteLine> list_routeline = new ArrayList<RouteLine>();
List<LatLng> latLngs = new ArrayList<LatLng>();
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文章

Android开发图片二级缓存

2021-2-1 9:15:24

Android文章

Android webview加载页面

2021-2-1 10:09:52

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索