Initial Integration HIccups

Few clarifications required as below for integrations

I: I see the below in the docs of MapMyIndia

compileOptions {

sourceCompatibility 1.8

targetCompatibility 1.8

}

We have Java 11. Is that a problem?

II: Add your API keys to the SDK (in your application’s onCreate() or before using map)

I have MainActivity.kt. Adding it in this class is sufficient ?

package

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {

}

MapmyIndiaAccountManager.getInstance().restAPIKey = “SET_REST_API_KEY”

MapmyIndiaAccountManager.getInstance().mapSDKKey = “SET_MAP_KEY”

MapmyIndiaAccountManager.getInstance().atlasClientId = “SET_CLIENT_ID”

MapmyIndiaAccountManager.getInstance().atlasClientSecret = “SET_CLIENT_SECRET”

MapmyIndia.getInstance(applicationContext)

III: Add a MapmyIndia Map to your application - Any spedfic file to be added to ?

<com.mapmyindia.sdk.maps.MapView

android:id=“@+id/map_view”

android:layout_width=“match_parent”

android:layout_height=“match_parent”/>

Hi @dwaipayansom_1731909

Mappls Flutter SDK : GitHub - mappls-api/mappls-flutter-sdk: This SDK is wrapper for Flutter on Native Map SDK to support on Android and iOS.
Mappls Android SDK : GitHub - mappls-api/mappls-android-sdk: A collection of Mappls's Map and others SDKs for Native android Development.

Java Version & Compile Options

compileOptions {
    sourceCompatibility 1.8
    targetCompatibility 1.8
}

This means that the Mappls SDK is compiled with Java 8 compatibility. It does not prevent you from using Java 11 in your project.

  • Using Java 11:
    You can use Java 11. The compile options ensure that the generated bytecode is compatible with Java 8, which is the standard for many Android projects. Just make sure that your Gradle and Android Gradle Plugin versions support Java 11.

Adding API Keys in MainActivity.kt

  • Where to Initialize:
    You need to initialize the API keys before you use any Mappls functionality. Placing the initialization in your MainActivity is acceptable.
  • Implementation Detail:
    Make sure you override the onCreate() method in your MainActivity to run the initialization code. For example:
package your.package.name

import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import com.mapmyindia.sdk.maps.MapmyIndia
import com.mapmyindia.sdk.maps.api.MapmyIndiaAccountManager

class MainActivity : FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        // Initialize API keys
        MapmyIndiaAccountManager.getInstance().restAPIKey = "SET_REST_API_KEY"
        MapmyIndiaAccountManager.getInstance().mapSDKKey = "SET_MAP_KEY"
        MapmyIndiaAccountManager.getInstance().atlasClientId = "SET_CLIENT_ID"
        MapmyIndiaAccountManager.getInstance().atlasClientSecret = "SET_CLIENT_SECRET"
        
        // Initialize MapmyIndia SDK with application context
        MapmyIndia.getInstance(applicationContext)
    }
}

This ensures that your keys are set up properly before any Map operations are performed.

Adding the MapMyIndia Map (XML Layout)

  • Placement of XML Code:
    The XML snippet for the MapView:
<com.mapmyindia.sdk.maps.MapView
    android:id="@+id/map_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

should be added to the layout XML file where you want the map to appear. For example, if your activity uses activity_main.xml as its layout, you can include it there.

  • Integration in Layout:
    If you’re using an Activity or Fragment, add the <MapView> element to the appropriate XML file. Then, in your Kotlin/Java code, you can reference and manage this view as needed.

Thank you for the above response. It helped
The code below is the current structure

import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import com.mappls.sdk.maps.*

class MainActivity : FlutterActivity() {
   override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.base_layout)
    mapView = findViewById(R.id.map_view)
    mapView.onCreate(savedInstanceState)

    MapplsAccountManager.getInstance().restAPIKey = "somekey"
    MapplsAccountManager.getInstance().mapSDKKey = "somekey"
    MapplsAccountManager.getInstance().atlasClientId = "someId"
    MapplsAccountManager.getInstance().atlasClientSecret = "somesec"
    Mappls.getInstance(applicationContext)
}

override fun onStart() {
    super.onStart()
    mapView.onStart()
}

override fun onResume() {
    super.onResume()
    mapView.onResume()
}

override fun onPause() {
    super.onPause()
    mapView.onPause()
}

override fun onStop() {
    super.onStop()
    mapView.onStop()
}

override fun onDestroy() {
    super.onDestroy()
    mapView.onDestroy()
}

override fun onLowMemory() {
    super.onLowMemory()
    mapView.onLowMemory()
}

override fun onSaveInstanceState(outState: Bundle) {
    super.onSaveInstanceState(outState)
    mapView.onSaveInstanceState(outState)
}

}

Also in pubspec.yaml I have added mappls_gl: ^1.1.2
I have under app/res/layout the file called base_layout and map_view.xml
dependencies {
implementation ‘com.mappls.sdk:mappls-android-sdk:8.2.1’
}
in app/build.gradle

I get the below errors
Unresolved reference: mapView
Unresolved reference: MapplsAccountManager

Reference link Refrence Guide to update SDK from v7+ to v8.0.0 | Map API | Android iOS SDKs | iOS SDKS | Mapping & location APIs & SDKs - Mappls