Start a Project

Working with AMap in Android – Part 4 (Adding Tile Overlay and Regeocode)

In the last part of the working with AMaps, we learned about adding marker click event and info windows. Now we will learn about adding Tile overlay on the Amap.

 

As we know that Amaps is a Chinese product and it provides services for China because China doesn’t support Google Services. In the default version of Amaps, you will not be able to see the detailed maps of the countries other than China. To be able to see the maps for the whole world you need to enable the tile overlay. TileOverlay actually covers the map with another image which contains a detailed map of the whole world.

To get the tile overlay on your Amap you need to use addTileOverlay() function of your Amap object. You can look at the code given below for an example.

this will automatically cache the images so that when you open the same area it won’t take much longer to load.

 

Secondly, In this blog, we will learn about the getting an address from the latitude and longitude and this is known as Regeocoding. For this, you need to implement an interface in your class GeocodeSearch.OnGeocodeSearchListener. The interface contains two methods which you need to override. First one is onGeocodeSearched(GeocodeResult geocodeResult, int i) which is used when you need to get the latitude and longitude of the location from its name and the other one is onRegeocodeSearched(RegeocodeResult result, int rCode) which is used to get the address from the Latitude and Longitude.

After implementing the interface, you need to initialize a LatLongPoint object and create an object of GeocodeSearch which is being used the get the lat long or the address. You need to set a listener on GeocodeSearch Object so that it returns the result in the onRegeocodeSearched function.

Now you need to create a RegeocodeQuery object and pass it to the getFromLocationAsyn function.

Now if your Latitude and Longitude are correct it will return a list of addresses in your onRegeocodeSearched(RegeocodeResult result, int rCode) function and to get the result you can follow the below code.

That’s all for this section, Use the locations and addresses as per your requirements.

Thank you very much, this is Vedesh Kumar signing off.

Exit mobile version