-1

how to insert image markerOption on google map for Android

Picture Figure 1.1

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

code

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);

            }

help me!!

Kung
  • 33
  • 5
  • You can check this - http://stackoverflow.com/questions/14811579/android-map-api-v2-custom-marker-with-imageview (Android Map api v2 Custom marker with ImageView) and there's a solution for that Question. – Vishnu Haridas Mar 15 '14 at 21:23

1 Answers1

0

This small snippet will do

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

For more options which is a lot like You can customize your markers by changing the default color, or replacing the marker icon with a custom image. Info windows can provide additional context to a marker

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

Arjun Chaudhary
  • 2,373
  • 2
  • 19
  • 36