Overview

Mapsted Mobile SDK

Current Version: v3.4.4

Android Support Minimul Level: Android v7.0, API Level 24 (Java Support Only)


Real Time Positioning

All-In-One Deluxe Lite

Use Mapsted's positioning technology to accurately show user positioning in indoor spaces and indoor plus oudoor spaces.

User Position

Getting the user position: Initialize MapstedPositioningApi(MapstedPositioningLite) by passing an implementation of MapstedInitializationCallback(give link). Implement OnPositionChangeListener(link) and override onPositionchanged method. Use the Position parameter to get user location, property ID, building ID and floor ID.

// Ask for location permission, Mapsted's PermissionChecks class can be used for that.
// After MapstedPositioningApi is been setup, a listener can be added to get position changes.
MapstedPositioningApi.getInstance().setOnPositionChangeListener(MainActivity.this);

// Implement OnPositionChangeListener and override the method onPositionChanged
// Get a callback to this method everytime a user changes position
 @Override
 public void onPositionChanged(final Position position) {
        //Position object contains X and Y coordinates for user position
        String userPosition = "User Location: " + position.getX() + ", " + position.getY();
    });
}

Support multiple coordinate system

Use Mapsted's Lite sdk's MapCalc(link) class for converting EPSG to (Lat, Lng) and vice versa

Mercator mercator = MapCalc.toMercator(location); // From Lat, Lng to EPSG:3857
LatLng latLng = MapCalc.toLatLng(mercator.getX(), mercator.getY());  // From EPSG:3857 to Lat, Lng

Property and Building

All-In-One Deluxe Lite

Multi-building support

Get property information (PropertyInfo) and building information (BuildingInfo) using MapstedPositioningApi:

// Retrieve the list of properties for your licence
ArrayList<PropertyInfo> properties = MapstedPositioningApi.getInstance().getAllProperties();
// Retrieve a list of the buildings by property of choice
if (properties != null && properties.size() > 0) {
    // For example, using the first property retrieved on the previous line.
    ArrayList<BuildingInfo> buildingsByProperty = MapstedPositioningApi.getInstance().getAllBuildingsByProperty(properties.get(0));
}

Get a specific property and building info and data. BuildingInfo or PropertyInfo gives less details than BuildingDataUI or PropertyData.

// get a specific property's info
PropertyInfo propertyInfo = MapstedPositioningApi.getInstance().getPropertyInfo(propertyId);
// get a specific property's data
PropertyData propertyData = MapstedPositioningApi.getInstance().getCachedPropertyData(propertyId);

// get a specific building's info
BuildingInfo buildingInfo = MapstedPositioningApi.getInstance().getBuildingInfo(buildingId);
// get a specific building's data
BuildingDataUI buildingData = MapstedPositioningApi.getInstance().getCachedBuildingData(buildingId);

Multi-floor support

Get the floor list by building: Get the list of FloorInfo by passing BuildingInfo. Refer Multi-building support(link) for fetching PropertyInfo and BuildingInfo list

/* Get all properties and buildings by the property of choice. Refer "Multi-building support"(link). */
if (buildingsByProperty != null && buildingsByProperty.size() > 0) {
    // get all floors by building
    ArrayList<FloorInfo> floorsByBuilding = MapstedPositioningApi.getInstance().getFloorListByBuilding(buildingsByProperty.get(0));
}

Download property data

Download PropertyData(link) using MapstedPositioningApi instance. Pass the required property's id and the OnMapDataDownloadedListener(link)

// To prefetch all the properties before setup use MapstedMapApi.setPrefetchMapData(true)(link)
// Use this api to download PropertyData for a specific property ID.
MapstedPositioningApi.getInstance().startPropertyDownload(propertyId, new OnMapDataDownloadedListener() {
    @Override
    public void onMapDownloaded(boolean isSuccessful, Common.MapDataType mapDataType, int mapDataId) {
        // The map has downloaded
    }

    @Override
    public void onDownloadProgressUpdate(int i, int i1) {
        // Track the download progress
    }
});

Get selected building's data in BuildingDataUI(link) object.

SelectedLocation selectedLocation = MapstedMapApi.getSelectedLocation();

BuildingDataUI buildingData = selectedLocation.getBuildingData();

Get tree of categories from a property

Get a list of the categories available for a property

PropertyData propertyData = MapstedMapApi.getSelectedLocation().getPropertyData();
if (propertyData == null) {
    return null;
}
PropertySearchFilters filters = propertyData.getPropertySearchFilters();
if (filters == null) {
    return null;
}
categoryTree = filters.getCategoryTree();

Get stores(SearchEntity) from a property

Fetch a list of stores (SearchEntity) from a property, including property and building data (supporting multi-building properties)

int propertyId = MapstedMapApi.getSelectedLocation().getPropertyId();
if (propertyId != null) {
    // Response might be null
    ArrayList<SearchEntity> entities = MapstedMapApi.getSearchEntityListByPropertyId(propertyId);
}

Routing

All-In-One Deluxe Lite

Use our advanced routing technology to show optimal routes to get around selected properties.

Accessibility routing (choose elevator/escalator/stairs)

Use RouteOptions(link) for including stairs, escalators or elevators

// Create RouteOptions object and set settings for stairs, escalators and elevators 
// For further usage: Refer the section 'Multi-destination routing' 
RouteOptions routeOptions = new RouteOptions();
routeOptions.setIncludeStairs(true);
routeOptions.setIncludeEscalators(true);
routeOptions.setIncludeElevators(true);

Optimized route

Use RouteOptions(link) for setting optimized route to true

// Set optimize route to true in RouteOptions and get the optimized order for navigation 
// For further usage: Refer the section 'Multi-destination routing' 
routeOptions.setOptimizeRoute(true);

Routing in order

Use RouteOptions(link) for setting optimized route to false and keep the destinations to navigate in order

// Set optimize route to false in RouteOptions
// For further usage: Refer the section 'Multi-destination routing' 
routeOptions.setOptimizeRoute(false);

Multi-destination routing

Use MapstedMapNotification(link) to add listener and post routing specific notifications.

//Setup listeners for routing and notification related to routing
MapstedMapNotification.addListener(this); // Pass a reference to the object that implements OnMapNotifiedListener
MapstedMapNotification.post(MapstedMapNotification.Type.routing);

Create a RouteRequestBuilder to do a route request.

RouteRequestBuilder routeRequestBuilder = new RouteRequestBuilder();
// Set routing options
routeRequestBuilder.setRouteOptions(routingOptions);

Pass one or more objects that implement ISearchable as starting point or destinations.

// If not start routing from my location
routeRequestBuilder.setStartSearchable(ISearchable);
// Start routing from my location
routeRequestBuilder.addDestination(Isearchable);

Create RouteRequest(link) object and use RoutingApi(link) to request route.

RouteRequest routingRequest = routeRequestBuilder.build();
// Request route
MapstedPositioningApi.getInstance().requestRoute(routingRequest);
 ```

Listen for "MapstedMapNotification.Type.routing"(link) notification using onMapNotified callback from OnMapNotifiedListener(link) interface

``` java tab="Android (Java)"
//Implement OnMapNotified interface
@Override
public void onMapNotified(MapstedMapNotification.Type type) {
    if (type == MapstedMapNotification.Type.routing) {
        // Get RouteResponse
        RouteResponse routeResponse = MapstedMapApi.getRoutingResponse()
    }
}

Auto re-routing

Use MapstedMapNotification(link) class for adding the listener and posting "MapstedMapNotification.Type.routingRecalculation" notification type. Implement OnMapNotifiedListener(link) interface, override onMapNotified callback and check for type "MapstedMapNotification.Type.routingRecalculation"

//Setup listeners for re-routing 
MapstedMapNotification.addListener(this); // Pass Activity/Fragment context
MapstedMapNotification.post(MapstedMapNotification.Type.routingRecalculation);
//Implement OnMapNotifiedListener interface
//Override onMapNotified method
 @Override
 public void onMapNotified(MapstedMapNotification.Type type) {
    if (type == MapstedMapNotification.Type.routingRecalculation) {
        // Get updatedRouteResponse
        RouteResponse routeResponse = MapstedMapApi.getRoutingResponse()
        // Handle appropriate UI activities
    }
}

Get Routing Information

Use MapstedMapApi(link) for getting the RoutingResponse(link). Create Route(link) object and use it for getting Route related information

if (MapstedMapApi.getRoutingResponse() == null){
    // handle null case
}
if (MapstedMapApi.getRoutingResponse().getRoutes().get(0) == null) {
    // handle null case 
}
// get the route
Route route = new Route(MapstedMapApi.getRoutingResponse().getRoutes().get(0));

Route Instructions

Get all instructions per route: Use MapstedMapApi(link) to get the current route number. Get RouteVector(link) using getRoutingResponse. Get RouteSegmentVector using RouteVector object. Iterate through all the segment and check for key route node. Get instructions from every key route node

int currentRouteNumber = MapstedMapApi.getCurRouteSegmentNum(); // Current route 
ArrayList<RouteNode> keyRouteNodes = new ArrayList<>();
RouteVector routeVector = MapstedMapApi.getRoutingResponse().getRoutes(); // All routes 
RouteSegmentVector routeSegmentVector = routeVector.get(currentRouteNumber).getSegments(); // All route segments per route number 

for (int i = 0; i < routeSegmentVector.size(); i++) {
    RouteSegment routeSegment = routeSegmentVector.get(i);
    for (int j = 0; j < routeSegment.getRouteNodes().size(); j++) {
        RouteNode routeNode = routeSegment.getRouteNodes().get(j);
        if (routeNode.isKeyPoint()) {
            keyRouteNodes.add(routeNode);
            instructions.add(routeNode.getInstruction()); // Set instruction
        }
    }
}

Route Preview

Using Mapsted's Positioning Lite sdk's RoutingApi(link), you can request route and get the callback for onMapNotified. Refer to "Multi-destination routing(link)" for setting up the listeners for routing

RoutingApi.getInstance().requestRoute(routingRequest); // Draws route on the map

All-In-One

Using Mapsted's All-in-One sdk, routing and navigation gets taken care of automatically. Refer the setup guide for All-in-one sdk(link)


Landmark-based instructions

Refer to "Route Instructions" section. Every key route node has a landmark based instruction


Estimated route time

//To be given by c++ team

Customization Options

Customizable routing icons

Get RouteNode(link) and get instruction image Id or set custom image id to the necessary view

RouteNode routeNode = routeSegment.getRouteNodes().get(i); //where i is the index for each route node
/* Use route node's existing image id or set your custom image id on any image view */
mDirectionImage.setImageDrawable(routeNode.getInstructionImageId()); 

Customizable routing instructions

Refer to "Route Instructions"(link) section. There is a pre-set list of routing instructions per each key route node. Use that or create your own custom instruction list.

// Set custom instructions 
ArrayList<String> instructions = new ArrayList<>();
for (int i = 0; i < keyRouteNodes.size(); i++) {
    if (keyRouteNodes.get(i).getInstruction().contains("left")) {
        instructions.add("Take left"); // Create custom instruction text
    }
}

Map interactions

Map events (Idle, Stable, Moved)

Map Events for when map is idle, stable or is moved:

// Handle Map's event types
MapstedMapApi.getMapEvents().observe(this, mapEvent -> {
    switch (mapEvent.getEventType()) {
        case EventType.MAP_IDLE:
            break;
        case EventType.MAP_STABLE:
            break;
        case EventType.MAP_MOVED:
            break;
    }
});

Map clicks (Single, Double, Long, Dual, Deselect)

Map click events for when map is single, double or long clicked and for dual selection and deselection:

// Handle Map's click types 
MapstedMapApi.getMapClickEvents().observe(this, mapClickEvent -> {
    switch (mapClickEvent.getClickType()) {
        case CLICK_TYPE_SINGLE:
            break;
        case CLICK_TYPE_DOUBLE:
            break;
        case CLICK_TYPE_LONG:
            break;
        case CLICK_TYPE_DUAL:
            break;
        case CLICK_TYPE_DESELECT:
            break;
    }
});

Native map user experience

Automatic zoom, tilt and rotate functionalities

Use Settings.Navigation static class to set auto zoom, auto rotate and auto tilt map behaviour

Settings.Navigation.isAutoZoom = true;
Settings.Navigation.isAutoRotateMap = true;
Settings.Navigation.isAutoTilt = true;

Ability to customize zoom, tilt and rotate

Add custom parameters for map view events like zoom, tilt and rotate. Create a list of UpdateMapViewEvent(link). Add individual map view events with the necessary values. Set the map view events on UpdateMapEvent(link) object and call onUpdateMapEvent passing updateMapEvent object

ArrayList<UpdateMapViewEvent> updateMapViewEvents = new ArrayList<>();
// Add the required map view events
// Specify the type of event, value for that event and the speed at which you want the event to occur
updateMapViewEvents.add(new UpdateMapViewEvent(UpdateMapViewEvent.TILT, 45.0f, 1.0f));
updateMapViewEvents.add(new UpdateMapViewEvent(UpdateMapViewEvent.ZOOM, 20.0f, 0.5f));
updateMapViewEvents.add(new UpdateMapViewEvent(UpdateMapViewEvent.RECENTER, 0f, 0.5f));
updateMapViewEvents.add(new UpdateMapViewEvent(UpdateMapViewEvent.ROTATE, 0f, 0.5f));

UpdateMapEvent updateMapEvent = new UpdateMapEvent();
updateMapEvent.setUpdateMapViewEvents(updateMapViewEvents);
MapstedMapApi.onUpdateMapEvent(updateMapEvent);
Ability to recenter map

Use Deluxe sdk's MapstedMapApi(link) to call centerPropertyInMap method

MapstedMapApi.centerPropertyInMap()

Outdoor base map

Use MapstedMapApi(link) to downlaod the outdoor map by a single api call. Make this call after appropriate permission checks. You can use Mapsted's PermissionChecks class to check permissions

// Pass the object of AppCompatActivity 
MapstedMapApi.downloadBasemapLayer(mActivity);

Mapsted Map

All-In-One Deluxe

The Mapsted Map offers a visual interface powered by Mapsted's technology to not only show user positioning but also display, points of interest, popups, and more.

![]

Adding the Map Fragment

Use MapstedMapApi(link) and addMapFragment api to add the map fragment

FrameLayout mapLayout = new FrameLayout(MainActivity.this);
//Adding Map Fragment
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
MapstedMapApi.addMapFragment(mapLayout.getId(), ft);

Drawing on the Map

Drawing the Property: Use MapstedMapApi(link) and selectPropertyAndDrawIfNeeded api to select and draw property. Pass in the required propertyId and OnSetSelectedPropertyListener(link) in the api

int propertyId; // Use the required propertyId
MapstedMapApi.selectPropertyAndDrawIfNeeded(propertyId, new OnSetSelectedPropertyListener() {
    @Override
    public void onSetSelectedProperty(boolean b) {
    }
});

Drawing the Building: Use MapstedMapApi(link) and selectBuildingAndDrawIfNeeded api to select and draw building. Pass in the required buildingId and OnSetSelectedBuildingListener(link) in the api

int buildingId; // Use the required buildingId
MapstedMapApi.selectBuildingAndDrawIfNeeded((buildingId, new OnSetSelectedBuildingListener() {
    @Override
    public void onSetSelectedBuilding(boolean b) {
    }
});

Update Map

Use UpdateMapEvent(link) class and onUpdateMapEvent api of MapstedMapApi(link) to get various events updates on the map

//Example of refocusing the map on a specified building
Mercator pos = MapstedPositioningApi.getCachedBuildingData(buildingId).getBuildingPolygons().getBuildingBoundary().getCentroid();
UpdateMapEvent updateMapEvent = new UpdateMapEvent();
updateMapEvent.setNewMapPos(pos);
MapstedMapApi.onUpdateMapEvent(updateMapEvent);

All-In-One

By input type (name, category, filters and keywords)

Use MapstedActivity(link) from All-in-One sdk to get the map and search feature together. Or you can use All-in-One sdk's SearchMapFragment(link) class to get only the search feature. Search by name, category, filters and keywords will be taken care by both the options mentioned above

// In MainActivity
// Use MapstedActivity for displaying the map and search feature 
Intent intent = new Intent(MainActivity.this, MapstedActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
MapstedMapApi.setup(MainActivity.this);
startActivity(intent);
//..
// Or
// Use MapstedActivity's changeToFragment method to directly change the frgament 
mapstedActivity.changeToFragment(SearchMapFragment.class, bundle);
//..
// Or
// Use SearchMapFragment for getting just the search feature
Fragment fragment = SearchMapFragment.class.getInstance();
fragmentManager.beginTransaction()
                .add(R.id.fl_content, fragment, fragmentClass.getSimpleName())
                .commitAllowingStateLoss();
//..

Plan My Trip

Allow the user to create an itinerary

All-In-One

Use Mapsted's All-in-One sdk's PlanMyRouteFragment which takes care of planning the route by adding the searched entities in the itinerary. It gives the flexibility to add, remove and update the items by simple drag and slide features

// In MainActivity
// Use MapstedActivity for displaying the map and plan my route feature
Intent intent = new Intent(MainActivity.this, MapstedActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
MapstedMapApi.setup(MainActivity.this);
startActivity(intent);
//..
// Or
// Use MapstedActivity's changeToFragment method to directly change the frgament 
mapstedActivity.changeToFragment(PlanMyRouteFragment.class, bundle);
//..
// Or
// Use PlanMyRouteFragment for getting just the search feature
Fragment fragment = PlanMyRouteFragment.class.getInstance();
fragmentManager.beginTransaction()
                .add(R.id.fl_content, fragment, fragmentClass.getSimpleName())
                .commitAllowingStateLoss();