4

I have a requirement where I have to show some location with the map view beside them. So I am planning to Put the Map view inside the row of Recycler view

Doing so will cost some performance issue. As map takes lots of memory. So I am reluctant to do so.

What are other options that I am left with? How can I Achieve that? Please help me in this..... Thanks

A.s.ALI
  • 1,992
  • 3
  • 22
  • 54
  • Use [Google Static Maps API](https://developers.google.com/maps/documentation/maps-static/intro?csw=1) ..Show the static map on list and on Click show the actual map with specified location ... – ADM May 13 '19 at 08:21
  • Google Maps Static APi is free? – A.s.ALI May 13 '19 at 08:22
  • NO .. Read the documentation.. – ADM May 13 '19 at 08:23
  • Then let me know any other solution – A.s.ALI May 13 '19 at 08:23
  • 1
    You shoud not put a map view inside list .map view itself is a very complex view involve intense rendering and all that.. you should look for some other option I guess ..maybe have a button to view the map on a new screen – ADM May 13 '19 at 08:27

1 Answers1

4

Use Lite Mode of Google Maps for do what you need:

Lite mode uses the same classes and interfaces as the full Google Maps Android API. You can set a GoogleMap to lite mode in the following ways:

  • Either as an XML attribute for a MapView or MapFragment
  • Or in the GoogleMapOptions object

As an XML attribute for a MapView or MapFragment

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:name="com.google.android.gms.maps.MapFragment"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    map:cameraZoom="13"
    map:mapType="normal"
    map:liteMode="true"/>

In the GoogleMapOptions object

GoogleMapOptions options = new GoogleMapOptions().liteMode(true);

Here is an official example for displaying maps efficiently in RecyclerView using lite mode.

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
  • @A.s.ALI Yep. Try it - it exactly for such case. – Andrii Omelchenko May 13 '19 at 10:23
  • how to implement same in iOS – A.s.ALI May 16 '19 at 08:59
  • @A.s.ALI [Lite Mode](https://developers.google.com/maps/documentation/android-sdk/lite) is for Android only. For iOS you can use [ Google Static Maps API](https://developers.google.com/maps/documentation/maps-static/intro?csw=1) as [ADM](https://stackoverflow.com/users/4168607/adm) mentioned. Or, if you have complex map (custom markers, fill, path etc.) you can create several screenshots of one `MapView` for each `RecyclerView` row. – Andrii Omelchenko May 16 '19 at 09:45
  • what If i show maps in every Cell of UITable. I am talking about iOS, in android I am going to use elite version of Google maps – A.s.ALI May 17 '19 at 03:43
  • @A.s.ALI Show Static API result (or MapView screenshot) as bitmap whenever you want. – Andrii Omelchenko May 17 '19 at 04:36
  • for some reasons I do not want to user Static API, but screenshot Idea is implementable. Please tell me in detail how I can took screenshot and what you have idea about it – A.s.ALI May 17 '19 at 05:00
  • @A.s.ALI Take a look at [this](https://stackoverflow.com/a/18093295/6950238) answer. – Andrii Omelchenko May 17 '19 at 05:13
  • This is all about android. All I am concerned now is about iOS – A.s.ALI May 17 '19 at 05:48
  • @A.s.ALI And [that](https://github.com/googlemaps/maps-sdk-for-ios-samples/blob/master/GoogleMaps/GoogleMapsDemos/Samples/SnapshotReadyViewController.m)? – Andrii Omelchenko May 17 '19 at 05:56