Skip to content

Latest commit

 

History

History
98 lines (75 loc) · 3.09 KB

File metadata and controls

98 lines (75 loc) · 3.09 KB

MapmyIndia APIs

MapmyIndia offers a range of preset styles to rendering the map. The user has to retrieve a list of styles for a specific account. The listing api would help in rendering specific style as well as facilitate the switching of style themes.

From the below reference code it would become quite clear that user has to specify style names and not URLs to use them. A default style is set for all account users to start with. To know more about available styles, kindly contact apisupport@mapmyindia.com

This feature is available from version v6.8.14

To get the list of available styles:

Java

List<MapmyIndiaStyle> styleList = mapmyIndiaMap.getMapmyIndiaAvailableStyles();

Kotlin

val styleList = mapmyIndiaMap.getMapmyIndiaAvailableStyles()

MapmyIndiaStyle contains below parameters:

  1. description(String): Description of the style
  2. displayName(string): Generic Name of style mostly used in MapmyIndia content.
  3. imageUrl(String): Preview Image of style
  4. name(String): Name of style used to change the style.

To set MapmyIndiaMaps style reference code is below:

Java

mapmyIndiaMap.setMapmyIndiaStyle(name, new OnStyleLoadListener() {  
       @Override  
       public void onError(String error) {  
            Toast.makeText(MapActivity.this, error, Toast.LENGTH_SHORT).show();  
       }  
  
       @Override  
       public void onStyleLoaded(Style styles) {   
           Toast.makeText(MapActivity.this, "onStyleLoaded", Toast.LENGTH_SHORT).show();  
  
       }  
});
                           //OR
mapmyIndiaMap.setMapmyIndiaStyle(name);

Kotlin

mapmyIndiaMap.setMapmyIndiaStyle(style, object : OnStyleLoadListener {
            override fun onError(p0: String?) {
                Toast.makeText(this@MainActivity, p0, Toast.LENGTH_LONG).show()
            }

            override fun onStyleLoaded(style: Style) {
                Toast.makeText(this@MainActivity, "Style loaded Successfully", Toast.LENGTH_LONG).show()
            }
        })
                           //OR
mapmyIndiaMap.setMapmyIndiaStyle(name)

To enable/disable loading of last selected style:

Java

MapmyIndiaMapConfiguration.getInstance().setShowLastSelectedStyle(false); //true is enable & false is disable(default value is true) 

Kotlin

MapmyIndiaMapConfiguration.getInstance().setShowLastSelectedStyle(false) //true is enable & false is disable(default value is true)

To get the currently selected style name:

Java

mapmyIndiaMap.getMapmyIndiaStyle();

Kotlin

mapmyIndiaMap.getMapmyIndiaStyle()

For any queries and support, please contact:

Email