我在地图上显示标记。我不确定如何为不同的标记指定不同的可绘制资源?
如果位置距离
pin = getResources().getDrawable(R.drawable.pushpin);
itemizedOverlay = new MyItemizedOverlay(pin, mapView);
for (Record element : list) {
GeoPoint point;
OverlayItem overlayItem;
double lat = Double.parseDouble(element.getLatitude());
double lng = Double.parseDouble(element.getLongitude());
double locationDistance = Double.parseDouble(element.getLocationDist());
geoPoint.add(new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)));
listOfOverlays = mapView.getOverlays();
point = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
Log.i("deep", "deep " + point);
overlayItem = new OverlayItem(point, "", element.getTitle());
if(locationDistance < 50){
//green
}
else if(locationDistance > 50 && locationDistance < 100){
//yellow
}
else if(locationDistance > 100 && locationDistance < 150){
//blue
}
答案 0 :(得分:4)
我能够使用setMarker()。见答案#3:
答案 1 :(得分:3)
我找到了setMarker方法正常工作的解决方案:
Drawable drawable = getResources().getDrawable(R.drawable....);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
overlayItem.setMarker(drawable);
答案 2 :(得分:1)