0
位圖圖像不drawing.i不明白爲什麼圖像正在繪製作爲標記在谷歌maps.is有任何其他方式來定製谷歌地圖標記爲圖像 我不能理解圖像是否是越來越加載或不自定義標記圖像不顯示在谷歌地圖
final LatLng MELBOURNE = new LatLng(-37.813, 144.962);
final URL url = new URL(
"http://indervilla.com/home/Mickey-Mouse-Cartoon-HD.jpg");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
Bitmap bmImg = BitmapFactory.decodeStream(is);
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
Bitmap bmp = Bitmap.createBitmap(80, 80, conf);
Canvas canvas1 = new Canvas(bmp);
// paint defines the text color,
// stroke width, size
Paint color = new Paint();
color.setTextSize(20);
color.setColor(Color.RED);
color.setStrokeWidth(10);
// modify canvas
canvas1.drawBitmap(bmImg, -10, -10, color);
// add marker to Map
googleMap.addMarker(new MarkerOptions().position(MELBOURNE)
.icon(BitmapDescriptorFactory.fromBitmap(bmp))
// Specifies the anchor to be at a particular point in the
// marker image.
.anchor(.5f, 1));
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(-37.813, 144.962)).zoom(15).build();
googleMap.animateCamera(CameraUpdateFactory
.newCameraPosition(cameraPosition));
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onResume() {
super.onResume();
initilizeMap();
}
/**
* function to load map If map is not created it will create it for you
* */
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
}
你可以告訴我如何使用它。我是一個初學者到android,我不熟悉使用外部庫 –
如果你看看我發佈的鏈接。有一個YouTube視頻解釋了一些基本的東西。我還沒有使用圖書館。 – Emmanuel