Mapping on Android with linkalist

linkalist
linkalist Blog
Published in
3 min readJun 15, 2019

After completing our basic mapping functionality on iOS the next step was to bring this functionality to Android. As a first step we’ve done this by extending the Android SupportMapFragment into a new linkalistMapFragment that does all of the work of interacting with the list data to display items as markers on a map.

Before getting involved adding maps, you’re going to need to set up your API access. The easiest way to get started on this is to create a new “Google Maps Activity” which will do all of the necessary setup work for your project. You’ll then need to set up your API and application cert before you can display a map. For details on this process, you should have a look at the Google developer docs. Once you’ve got the boilerplate map activity up and running you can delete it and set up the linkalist map.

The best way to get started with this is to extend this fragment and hook it into your application as you see fit.

public class SiteMapFragment extends linkalistMapFragment
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setListName(DiveListActivity.SITES_LIST_NAME);
}
}

You can plug this into an activity or a tab pager — whatever suits your application. But this gets you a minimum viable map in Android which will display a Google Map and plot points from the associated list on the map. There are however a few optional features you can use

Zoom Control

You can specify the initial zoom level of your map along with minimum and maximum values for the zoom.

setInitialMapZoom(13);
setMinimumMapZoom(6);
setMaximumMapZoom(16);

Marker Options

We’ve only got some basic options here for now and will add extra functionality in response to customer demand

setMarkerColor(BitmapDescriptorFactory.HUE_GREEN);
enableClustering(true);

This allows you to control the colour of your makers. In addition, enabling clustering combines markers close to each other into a common point which allows your map to be a little less cluttered.

Clicking on Markers

For now, the only available action available when clicking on a marker is to show an info window.

However, you can override a default handler in your extension of the linkalistMapFragment to add functionality to your app when the marker’s info window is clicked.

@Override
public void onMarkerInfoClick(String id)
{
List list = getList();

if ((null != list) && (StringHelper.containsSomething(id)))
{
}
}

Interested in this or other great linkalist features? Check out our beta programme.

--

--

linkalist
linkalist Blog

Empowering Entrepreneurs to build Web and Mobile Apps themselves — quickly, at low cost and with little or no code.