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