-
Notifications
You must be signed in to change notification settings - Fork 14
MapmyIndia Nearby Search Widget
The MapmyIndia Nearby Widget makes it easy to integrate the functionality to search nearby POIs for selected categories in your Android application. The Nearby Search widget provided as a means to enable radially search for Nearby Places on MapmyIndia Maps.
The widget offers the following basic functionalities:
-
Ability to search for nearby places directly with MapmyIndia Maps visual interface.
-
A single method to initiate nearby search across all categories of places available on MapmyIndia.
-
Ability to get information from MapmyIndia Nearby Search widget through a callback.
This can be done by following simple steps.
Step 1 :- Setup your Project
Follow these steps to add the widget to your project –
- Create a new project in Android Studio
- Add MapmyIndia repository in your project level build.gradle
allprojects {
repositories {
maven {
url 'https://maven.mapmyindia.com/repository/mapmyindia/'
}
}
}
- Add below dependency in your app-level build.gradle
implementation 'com.mapmyindia.sdk:nearby-ui:0.1.0'
Step 2 :- Adding Credentials
Add your API keys to the SDK (in your application's onCreate() or before using map)
MapmyIndiaAccountManager.getInstance().setRestAPIKey(getRestAPIKey());
MapmyIndiaAccountManager.getInstance().setMapSDKKey(getMapSDKKey());
MapmyIndiaAccountManager.getInstance().setAtlasClientId(getAtlasClientId());
MapmyIndiaAccountManager.getInstance().setAtlasClientSecret(getAtlasClientSecret());
MapmyIndia.getInstance(applicationContext);
MapmyIndiaAccountManager.getInstance().restAPIKey = getRestAPIKey()
MapmyIndiaAccountManager.getInstance().mapSDKKey = getMapSDKKey()
MapmyIndiaAccountManager.getInstance().atlasClientId = getAtlasClientId()
MapmyIndiaAccountManager.getInstance().atlasClientSecret = getAtlasClientSecret()
MapmyIndia.getInstance(applicationContext)
Step 3 :- Launching Nearby Widget
There are two ways to implement Nearby Search
widget:
- Using
MapmyIndiaNearbyFragment
- Using
MapmyIndiaNearbyActivity
Add MapmyIndiaNearbyFragment in your activity:
MapmyIndiaNearbyFragment nearbyFragment = MapmyIndiaNearbyFragment.newInstance();
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, nearbyFragment, MapmyIndiaNearbyFragment.class.getSimpleName())
.commit();
val nearbyFragment: MapmyIndiaNearbyFragment= MapmyIndiaNearbyFragment.newInstance()
supportFragmentManager.beginTransaction().add(R.id.fragment_container, nearbyFragment, MapmyIndiaNearbyFragment::class.java.simpleName)
.commit()
To get the selected nearby place use IMapmyIndiaNearbyCallback interface:
nearbyFragment.setMapmyIndiaNearbyCallback(new IMapmyIndiaNearbyCallback() {
@Override
public void getNearbyCallback(NearbyAtlasResult nearbyAtlasResult) {
// Select place
}
});
nearbyFragment.setMapmyIndiaNearbyCallback(object : IMapmyIndiaNearbyCallback {
override fun getNearbyCallback(nearbyCallback: NearbyAtlasResult) {
//Select place
}
})
Add MapmyIndiaNearbyActivity in your activity:
Intent intent = new MapmyIndiaNearbyWidget.IntentBuilder().build(this);
startActivityForResult(intent, 101);
val intent = MapmyIndiaNearbyWidget.IntentBuilder().build(this)
startActivityForResult(intent, 101)
To get the selected POI:
@Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 101 && resultCode == RESULT_OK) {
NearbyAtlasResult result = MapmyIndiaNearbyWidget.getNearbyResponse(data);
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if(requestCode == 101 && resultCode == Activity.RESULT_OK) {
val place: NearbyAtlasResult? = MapmyIndiaNearbyWidget.getNearbyResponse(data!!)
} }
Email us at apisupport@mapmyindia.com
Ask a question under the mapmyindia-api
Need support? contact us!
Read about the latest updates & customer stories
© Copyright 2021. CE Info Systems Pvt. Ltd. All Rights Reserved. | Terms & Conditions.
- Map UI Settings
- Set Country Regions
- Set MapmyIndia MapStyle
- REST API Kit
- MapmyIndia GeoAnalytics
- Place Autocomple Widget
- MapmyIndia Safety Plugin
- MapmyIndia Interactive Layer
- MapmyIndia GeoFence View
- MapmyIndia Safety Strip
- MapmyIndia Place Picker
- MapmyIndia Scalebar Plugin
- ELocation Strategy
- MapmyIndia Direction Widget
- MapmyIndia Nearby Search Widget
- Version History
- Country List