Skip to content

Latest commit

 

History

History
526 lines (471 loc) · 16 KB

Reference-Guide.md

File metadata and controls

526 lines (471 loc) · 16 KB

MapmyIndia APIs

Refrence Guide to update SDK from v6+ to v7.0.0

Map SDK

Change Imports

  1. Change imports com.mapbox.mapboxsdk.* to com.mapmyindia.sdk.maps.*
  2. Change imports com.mapbox.mapboxsdk.maps.* to com.mapmyindia.sdk.maps.*
  3. Change imports com.mapbox.geojson.* to com.mapmyindia.sdk.geojson.*
  4. Change imports com.mapbox.turf.* to com.mapmyindia.sdk.turf.*
  5. Change imports com.mapbox.android.gestures.* to com.mapmyindia.sdk.gestures.*

Change Classes

  1. Change class MapboxMap to MapmyIndiaMap

Change in XML

Old SDK

<com.mapbox.mapboxsdk.maps.MapView  
  android:id="@+id/map_view"  
  android:layout_width="match_parent"  
  android:layout_height="match_parent"/>

New SDK

<com.mapmyindia.sdk.maps.MapView  
  android:id="@+id/map_view"  
  android:layout_width="match_parent"  
  android:layout_height="match_parent"/>

Change all attributes from mapbox_ to mapmyindia_maps_

Set Camera using ELoc

Old SDK

mapmyIndiaMap.moveCamera("MMI000", 14);
mapmyIndiaMap.easeCamera("MMI000", 14);
mapmyIndiaMap.animateCamera("MMI000", 14);

New SDK

mapmyIndiaMap.moveCamera(CameraELocUpdateFactory.newELocZoom("MMI000", 14));
mapmyIndiaMap.easeCamera(CameraELocUpdateFactory.newELocZoom("MMI000", 14));
mapmyIndiaMap.animateCamera(CameraELocUpdateFactory.newELocZoom("MMI000", 14));

Set Camera to Particular Eloc Bounds

Old SDK

mapmyIndiaMap.moveCamera(eLocList, 10, 10, 10, 10);
mapmyIndiaMap.easeCamera(eLocList, 10, 10, 10, 10);
mapmyIndiaMap.animateCamera(eLocList, 10, 10, 10, 10);

New SDK

mapmyIndiaMap.moveCamera(CameraELocUpdateFactory.newELocBounds(eLocs, 10 , 100, 10, 10));
mapmyIndiaMap.easeCamera(CameraELocUpdateFactory.newELocBounds(eLocs, 10 , 100, 10, 10));
mapmyIndiaMap.animateCamera(CameraELocUpdateFactory.newELocBounds(eLocs, 10 , 100, 10, 10));

Map Click/Long click

Old SDK

//Map click
mapmyIndiaMap.addOnMapClickListener(new MapboxMap.OnMapClickListener() {  
  @Override  
  public void onMapClick(@NonNull LatLng point) {  
    
  }  
});
//Map long click
mapmyIndiaMap.addOnMapLongClickListener(new MapboxMap.OnMapLongClickListener() {  
  @Override  
  public void onMapLongClick(@NonNull LatLng point) {  
    
  }  
});

New SDK

//Map click
mapmyIndiaMap.addOnMapClickListener(new MapmyIndiaMap.OnMapClickListener() {  
    @Override  
  public boolean onMapClick(@NonNull LatLng latLng) {  
    return false;  
 }  
});
//Map long click
mapmyIndiaMap.addOnMapLongClickListener(new MapmyIndiaMap.OnMapLongClickListener() {  
    @Override  
  public boolean onMapLongClick(@NonNull LatLng latLng) {   
        return false;  
  }  
});

Current Location

Old SDK

//Current Location Activation 
LocationComponentOptions options = LocationComponentOptions.builder(this)
                .foregroundDrawable(R.drawable.location_pointer)
                .build();
// Get an instance of the component LocationComponent
locationComponent = mapmyIndiaMaps.getLocationComponent();
// Activate with options
locationComponent.activateLocationComponent(this, options);
//LocationChange Listener
LocationEngineListener listener = new LocationEngineListener() {
	  
@Override  
public void onConnected() {  
  
}  
  
@Override  
public void onLocationChanged(Location location) {  
   
	}
};
//Add Location Change listener
locationEngine.addLocationEngineListener(this);
//Remove Location Change listener
locationEngine.removeLocationEngineListener(this);
//Request Location Update
locationEngine.requestLocationUpdates();
//Remove location update
locationEngine.removeLocationUpdates();

New SDK

//Current Location Activation 
LocationComponentOptions options = LocationComponentOptions.builder(this) 
                .foregroundDrawable(R.drawable.location_pointer)  
                .build();  
// Get an instance of the component LocationComponent  
  locationComponent = mapmyIndiaMap.getLocationComponent();  
  LocationComponentActivationOptions locationComponentActivationOptions = LocationComponentActivationOptions.builder(this, style)  
                .locationComponentOptions(options)  
                .build();  
// Activate with options  
locationComponent.activateLocationComponent(locationComponentActivationOptions);
//LocationChange Listener
LocationEngineCallback<LocationEngineResult> locationEngineCallback = new LocationEngineCallback<LocationEngineResult>() {  
    @Override  
  public void onSuccess(LocationEngineResult locationEngineResult) {  
        if(locationEngineResult.getLastLocation() != null) {  
            Location location = locationEngineResult.getLastLocation();    
        }  
    }  
  
    @Override  
  public void onFailure(@NonNull Exception e) {  
  
    }  
};
LocationEngineRequest request = new LocationEngineRequest.Builder(DEFAULT_INTERVAL_IN_MILLISECONDS)  
        .setPriority(LocationEngineRequest.PRIORITY_HIGH_ACCURACY)  
        .setMaxWaitTime(DEFAULT_MAX_WAIT_TIME).build();  
 ////Request Location Update & add location change callback
locationEngine.requestLocationUpdates(request, locationEngineCallback, getMainLooper());
//Remove location update & callback
locationEngine.removeLocationUpdates(locationEngineCallback);

Rest API

AutoSuggest

Old SDK

MapmyIndiaAutoSuggest.builder()  
        .query(searchText)  
        .build()  
        .enqueueCall(new Callback<AutoSuggestAtlasResponse>() {  
            @Override  
            public void onResponse(@NonNull Call<AutoSuggestAtlasResponse> call, @NonNull Response<AutoSuggestAtlasResponse> response) {  
                //handle response 
            }  
  
            @Override  
            public void onFailure(@NonNull Call<AutoSuggestAtlasResponse> call, @NonNull Throwable t) {  
                t.printStackTrace();  
            }  
        });

New SDK

MapmyIndiaAutoSuggest mapmyIndiaAutoSuggest = MapmyIndiaAutoSuggest.builder()  
        .query(searchString)  
        .build();  
MapmyIndiaAutosuggestManager.newInstance(mapmyIndiaAutoSuggest).call(new OnResponseCallback<AutoSuggestAtlasResponse>() {  
    @Override  
  public void onSuccess(AutoSuggestAtlasResponse autoSuggestAtlasResponse) {  
          //handle response 
    }  
  
    @Override  
  public void onError(int i, String s) {  
  
    }  
});

Geocoding API

Old SDK

MapmyIndiaGeoCoding.builder()  
        .setAddress("Delhi")  
        .build()  
        .enqueueCall(new Callback<GeoCodeResponse>() {  
            @Override  
            public void onResponse(Call<GeoCodeResponse> call, Response<GeoCodeResponse> response) {  
                //handle response 
            }     
  
            @Override  
            public void onFailure(Call<GeoCodeResponse> call, Throwable t) {  
                t.printStackTrace();  
            }  
        });

New SDK

MapmyIndiaGeoCoding mapmyIndiaGeoCoding = MapmyIndiaGeoCoding.builder()  
        .setAddress("Delhi")  
        .build();  
MapmyIndiaGeoCodingManager.newInstance(mapmyIndiaGeoCoding).call(new OnResponseCallback<GeoCodeResponse>() {  
    @Override  
    public void onSuccess(GeoCodeResponse geoCodeResponse) {  
          
    }  
  
    @Override  
    public void onError(int i, String s) {  
  
    }  
});

Reverse Geocode

Old SDK

MapmyIndiaReverseGeoCode.builder()  
        .setLocation(28, 77)  
        .build()  
        .enqueueCall(new Callback<PlaceResponse>() {  
            @Override  
            public void onResponse(Call<PlaceResponse> call,Response<PlaceResponse> response) {  
                //handle response 
           }  
  
            @Override  
            public void onFailure(Call<PlaceResponse> call, Throwable t) {  
                t.printStackTrace();  
            }  
        });

New SDK

MapmyIndiaReverseGeoCode mapmyIndiaReverseGeoCode = MapmyIndiaReverseGeoCode.builder()    
        .setLocation(28,77)    
        .build();    
MapmyIndiaReverseGeoCodeManager.newInstance(mapmyIndiaReverseGeoCode).call(new OnResponseCallback<PlaceResponse>() {    
    @Override    
  public void onSuccess(PlaceResponse response) {    
        //Handle Response  
  }    
    
    @Override    
  public void onError(int code, String message) {    
        //Handle Error  
  }    
});

Nearby API

Old SDK

MapmyIndiaNearby.builder()  
        .keyword("Parking")  
        .setLocation(28d, 77d)  
        .build()  
        .enqueueCall(new Callback<NearbyAtlasResponse>() {  
            @Override  
            public void onResponse(Call<NearbyAtlasResponse> call, Response<NearbyAtlasResponse> response) {  
                //handle response 
            }  
  
            @Override  
            public void onFailure(Call<NearbyAtlasResponse> call, Throwable t) {  
                t.printStackTrace();  
            }  
        });

New SDK

MapmyIndiaNearby mapmyIndiaNearby = MapmyIndiaNearby.builder()  
        .setLocation(28,77)    
        .keyword("Parking")    
        .build();    
MapmyIndiaNearbyManager.newInstance(mapmyIndiaNearby).call(new OnResponseCallback<NearbyAtlasResponse>() {    
    @Override    
  public void onSuccess(NearbyAtlasResponse response) {    
        //Handle Response  
  }    
    
    @Override    
  public void onError(int code, String message) {    
       //Handle Error  
  }    
});

eLoc

Old SDK

MapmyIndiaELoc.builder()  
        .setELoc("mmi000")  
        .build()  
        .enqueueCall(new Callback<PlaceResponse>() {  
            @Override  
            public void onResponse(Call<PlaceResponse> call, Response<PlaceResponse> response) {  
                //handle response 
            }  
  
            @Override  
            public void onFailure(Call<PlaceResponse> call, Throwable t) {  
                t.printStackTrace();  
            }  
        });

New SDK

MapmyIndiaELoc mapmyIndiaELoc = MapmyIndiaELoc.builder()    
        .setELoc("mmi000")    
        .build();    
MapmyIndiaELocManager.newInstance(mapmyIndiaELoc).call(new OnResponseCallback<PlaceResponse>() {    
    @Override    
  public void onSuccess(PlaceResponse response) {    
        //Handle Response   
  }    
    
    @Override    
  public void onError(int code, String message) {    
        //Handle Error  
  }    
});  

Place Detail

Old SDK

MapmyIndiaPlaceDetail.builder()  
        .eLoc("mmi000")  
        .build()  
        .enqueueCall(new Callback<PlaceDetailResponse>() {  
            @Override  
            public void onResponse(Call<PlaceDetailResponse> call, Response<PlaceDetailResponse> response) {  
                //handle response 
            }  
  
            @Override  
            public void onFailure(Call<PlaceDetailResponse> call, Throwable t) {  
                t.printStackTrace();  
            }  
        });

New SDK

MapmyIndiaPlaceDetail mapmyIndiaPlaceDetail = MapmyIndiaPlaceDetail.builder()    
        .eLoc("mmi000")    
        .build();    
MapmyIndiaPlaceDetailManager.newInstance(mapmyIndiaPlaceDetail).call(new OnResponseCallback<PlaceDetailResponse>() {    
    @Override    
  public void onSuccess(PlaceDetailResponse response) {    
        //Handle Response    
  }    
    
    @Override    
  public void onError(int code, String message) {    
       //Handle Error  
  }    
});

POI Along the Route

Old SDK

MapmyIndiaPOIAlongRoute.builder()  
        .category(catCode)  
        .path(path)  
        .build().enqueueCall(new Callback<POIAlongRouteResponse>() {  
            @Override  
            public void onResponse(Call<POIAlongRouteResponse> call, Response<POIAlongRouteResponse> response) {  
                //handle response
            }  
  
            @Override  
            public void onFailure(Call<POIAlongRouteResponse> call, Throwable t) {  
               t.printStackTrace();
            }  
        });

New SDK

MapmyIndiaPOIAlongRoute poiAlongRoute = MapmyIndiaPOIAlongRoute.builder()    
        .category(catCode)  
        .path(path)    
        .build();    
MapmyIndiaPOIAlongRouteManager.newInstance(poiAlongRoute).call(new OnResponseCallback<POIAlongRouteResponse>() {    
    @Override    
  public void onSuccess(POIAlongRouteResponse response) {    
        //Handle Response    
  }    
    
    @Override    
  public void onError(int code, String message) {    
        //Handle Error  
  }    
});

Routing API

Old SDK

MapmyIndiaDirections.builder()  
        .origin(startPointLocal)  
        .steps(true)  
        .resource(DirectionsCriteria.RESOURCE_ROUTE_ETA)  
        .profile(DirectionsCriteria.PROFILE_DRIVING)  
        .overview(DirectionsCriteria.OVERVIEW_FULL)  
        .destination(endPointLocal)
        .build()  
        .enqueueCall(new Callback<DirectionsResponse>() {  
            @Override  
            public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {  
                //handle response 
	        }  
  
            @Override  
            public void onFailure(Call<DirectionsResponse> call, Throwable t) {  
                 t.printStackTrace();  
	        }  
        });

New SDK

MapmyIndiaDirections directions = MapmyIndiaDirections.builder()  
        .origin(startPointLocal)  
        .steps(true)  
        .resource(DirectionsCriteria.RESOURCE_ROUTE_ETA)  
        .profile(DirectionsCriteria.PROFILE_DRIVING)  
        .overview(DirectionsCriteria.OVERVIEW_FULL)  
        .destination(endPointLocal)
        .build();
MapmyIndiaDirectionManager.newInstance(directions).call(new OnResponseCallback<DirectionsResponse>() {  
    @Override  
    public void onSuccess(DirectionsResponse directionsResponse) {  
         
    }  
  
    @Override  
    public void onError(int i, String s) {  
         
    }  
});

Driving Distance Matrix

Old SDK

MapmyIndiaDistanceMatrix.builder()  
        .profile(DirectionsCriteria.PROFILE_DRIVING)  
        .resource(DirectionsCriteria.RESOURCE_DISTANCE)  
        .coordinate(Point.fromLngLat(80.502113, 8.916787))  
        .coordinate(Point.fromLngLat(28.5505073, 77.2689367))  
        .build()  
        .enqueueCall(new Callback<DistanceResponse>() {  
            @Override  
	        public void onResponse(Call<DistanceResponse> call, Response<DistanceResponse> response) {  
                //handle response 
	        }  
  
            @Override  
	        public void onFailure(Call<DistanceResponse> call, Throwable t) {  
                t.printStackTrace();  
	        }
        });

New SDK

MapmyIndiaDistanceMatrix distanceMatrix = MapmyIndiaDistanceMatrix.builder()  
        .profile(DirectionsCriteria.PROFILE_DRIVING)  
        .resource(DirectionsCriteria.RESOURCE_DISTANCE)  
        .coordinate(Point.fromLngLat(80.502113, 8.916787))  
        .coordinate(Point.fromLngLat(28.5505073, 77.2689367))  
        .build(); 
MapmyIndiaDistanceMatrixManager.newInstance(distanceMatrix).call(new OnResponseCallback<DistanceResponse>() {  
    @Override  
  public void onSuccess(DistanceResponse distanceResponse) {  
        
    }  
  
    @Override  
  public void onError(int i, String s) {  
        
  }  
});

For any queries and support, please contact:

Email Email us at [email protected]

Stack Overflow Ask a question under the mapmyindia-api

Support Need support? contact us!

Blog Read about the latest updates & customer stories

© Copyright 2022. CE Info Systems Ltd. All Rights Reserved. | Terms & Conditions