簡體   English   中英

google map api v2從url android添加圖標

[英]google map api v2 add icon from url android

我有一個項目,從Web服務檢索緯度和經度,我將它們添加到谷歌地圖標記。 我想從網址添加標記的自定義圖標。

    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;
    }
}
try{
                        URL url = new URL(Lurl);
                        /** Creating an http connection to communcate with url */
                        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
                        /** Connecting to url */
                        urlConnection.connect();
                        /** Reading data from url */
                        iStream = urlConnection.getInputStream();
                        /** Creating a bitmap from the stream returned from the url */
                        bitmap = BitmapFactory.decodeStream(iStream);

                    }catch(Exception e){
                        Log.d("Exception while downloading url", e.toString());
                    }finally{
                        iStream.close();
                    }

這對我有用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM