Unable to see multiple marker on google Map

后端 未结 3 1899
灰色年华
灰色年华 2021-01-21 04:53

I want to show multiple markers on a google map. My latlng coordinates are fetched from a Parse database but I am not able see marker. My second problem is that I

3条回答
  •  时光取名叫无心
    2021-01-21 05:57

    I see a few problems here.

    As @Raghunandan mentioned, you cannot update the UI from doInBackground() so you cannot add markers from there. You can however, make your MarkerOptions objects here, and then attach them to the GoogleMap in your postExecute/or in the Activity that hosts the Google Maps.

    In your onPostExecute(), you have not set any Title, or Snippet to your markers. Whenever you are creating your marker, make sure to set your title. Then when the user clicks on the marker, the default behavior shows your rest name as a title. Code will be something like this(as also mentioned by @Inzimam Tariq IT :

    MarkerOptions markerOptions = new MarkerOptions();
                    markerOptions.position(res)
                    .setTitle(restaurantName)
                    .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
                    googleMap.addMarker(markerOptions);
    

提交回复
热议问题