其他分享
首页 > 其他分享> > 谷歌地图api v2从URL android添加图标

谷歌地图api v2从URL android添加图标

作者:互联网

我有一个从Web服务检索纬度和经度的项目,并将它们添加到Google地图标记中.我想为网址中的标记添加自定义图标.

    mMap.addMarker(new MarkerOptions()
                    .position(new LatLng(dlat,Dlong))
                    .title(m.group(9))
                    .draggable(false)                                           
                    .snippet(m.group(1)+" "+m.group(10)));

如何从链接中添加带有自定义图标的.icon?

解决方法:

Use this method and use returned bitmap to display in map





public Bitmap getBitmapFromURL(String imageUrl) {
    try {
        URL url = new URL(imageUrl);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setDoInput(true);
        connection.connect();
        InputStream input = connection.getInputStream();
        Bitmap myBitmap = BitmapFactory.decodeStream(input);
        return myBitmap;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}

标签:google-maps,google-maps-markers,android,google-maps-api-2
来源: https://codeday.me/bug/20191121/2053922.html