【问题标题】:how to insert image markerOption [Android]如何插入图片markerOption [Android]
【发布时间】:2014-03-28 14:52:56
【问题描述】:

如何在 Android 的谷歌地图上插入图像标记选项

图1.1

http://i.stack.imgur.com/PNcEm.png

代码

try {

            for(int i = 0; i < data.length(); i++){
                JSONObject c = data.getJSONObject(i);

                map = new HashMap<String, String>();
                map.put("latitude", c.getString("poi_latitude"));
                map.put("longitude", c.getString("poi_longitude"));
                map.put("ImgPath", c.getString("images_path"));
                map.put("ImgName", c.getString("images_name"));


                MyArrList.add(map);

                String Image = MyArrList.get(i).get("ImgPath" + "ImgName");

                String Image1 = "<img src='" + Image + "'" + "width='42' height='42'>";
                Spanned spannedContent = Html.fromHtml(Image1, getImageHTML(), null);

                MarkerOptions markerOption = new MarkerOptions();
                markerOption.title(MyArrList.get(i).get("name"));
                //markerOption.icon(BitmapDescriptorFactory.fromBitmap(bitmap));
                markerOption.snippet(spannedContent.toString());
                LatLng latlng = new LatLng(Double.parseDouble(MyArrList.get(i).get("latitude")), Double.parseDouble(MyArrList.get(i).get("longitude")));
                markerOption.position(latlng);

                mMap.addMarker(markerOption);

            }

帮帮我!!

【问题讨论】:

标签: java android html


【解决方案1】:

这个小sn-p就可以了

private GoogleMap mMap;
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.addMarker(new MarkerOptions()
        .position(new LatLng(0, 0))
        .title("Hello world"));

如需更多选项,您可以通过更改默认颜色或将标记图标替换为自定义图像来自定义标记。信息窗口可以为标记提供额外的上下文

REFER:= https://developers.google.com/maps/documentation/android/marker

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-28
    • 2013-03-08
    • 2018-02-26
    • 1970-01-01
    • 2023-03-03
    相关资源
    最近更新 更多