Skip to content

Latest commit

 

History

History
250 lines (160 loc) · 11 KB

InteractiveLayers.md

File metadata and controls

250 lines (160 loc) · 11 KB

Interactive Layers Plugin - Mappls Map

It is a guide to display Interactive Layers(such as Covid WMS Layers) on Mappls's Map.

In the current scenario, where social distancing is paramount, technology is playing a key role in maintaining daily communication and information transfer. Mappls is serving individuals, companies and the government alike, to spread critical information related to COVID-19 through deeply informative, useful and free-to-integrate geo-visualized COVID-19 Layers in your application.

Following this COVID - 19 guide it will be possible to display different Covid 19 related areas, zone and location on Mappls's Map[1] for iOS. MapplsMap SDK for iOS is SDK to display map on iOS platform.

It would be extremely helpful for people who are looking forward to joining offices or visiting markets etc. This tool can help you check the zone and other details of any area.

On launch of Mappls's Map[1], List of available layers can be fetched/refreshed from server by calling method getCovidLayers of map object. Layers can be accessed by property interactiveLayers of map as explained in section Access Layers.

A delegate method mapViewInteractiveLayersReady will be called when it successfully fetches list of layers from server. This method can be accessed by refereing delegate of map object to any ViewController and implementing protocol class MapplsMapViewDelegate. Go to section Layers Ready Callback for more details.

Map Authorization is part of MapplsMap SDK. Map will only display if your keys are provisoned to display map.

A delegate method authorizationCompleted from Maps SDK is called onece it checks for Map Authorization.

This delegate method is called when Maps authorization process completes. In delegate method a boolean property isSuccess receives which represents is authorization successed or not.

Note: getCovidLayers function will only work if Map SDK is authenticated. So best place to call this function is in delegate method authorizationCompleted.

Objective-C
- (void)mapView:(MapplsMapView *)mapView authorizationCompleted:(BOOL)isSuccess
{
    if(isSuccess) {
        [self.mapView getCovidLayers];
    }
}
Swift
func mapView(_ mapView: MapplsMapView, authorizationCompleted isSuccess: Bool) {
    if isSuccess {
        self.mapView.getCovidLayers()
    }
}

Delegate method mapViewInteractiveLayersReady is called when it successfully fetches list of layers after calling function getCovidLayers.

So get ready your application once pointer comes to this delegate method.

A scenario can be made in application to allow or disallow to access WMS layers using this deleage method. Please see below code for reference:

Objective-C
- (void)mapViewInteractiveLayersReady:(MapplsMapView *)mapView
{
    // Put your logic here to allow to access WMS layers, either by some boolean property or by setting visiblity of a button as it is demonstrated in sample.
    if (self.mapView.interactiveLayers && self.mapView.interactiveLayers.count > 0) {
        [_covid19Button setHidden:NO];
    }
}
Swift
func mapViewInteractiveLayersReady(_ mapView: MapplsMapView) {
    // Put your logic here to allow to access WMS layers, either by some boolean property or by setting visiblity of a button as it is demonstrated in sample.
    if self.mapView.interactiveLayers?.count ?? 0 > 0 {
        covid19Button.isHidden = false
    }
}

List of available layers can be accessed using porperty interactiveLayers which is type of an array of MapplsInteractiveLayer class.

Note: Fetching of list of layers will only succeed if your Authorization keys for map are provisoned to get these layers otherwise this will be an empty list.

Objective-C
NSArray<MapplsInteractiveLayer *> *interactiveLayers = self.mapView.interactiveLayers;
Swift
let interactiveLayers = self.mapView.interactiveLayers

MapplsInteractiveLayer class has two properties layerId and layerName.

layerId is unique identifier for a layer using which a layer can be shown or hide on map

layerName is display name for a layer which can be used to show in a list or label.

List of available layers can be accessed using porperty visibleInteractiveLayers.

Objective-C
NSArray<MapplsInteractiveLayer *> *visibleInteractiveLayers = self.mapView.visibleInteractiveLayers;
Swift
let visibleInteractiveLayers = self.mapView.visibleInteractiveLayers

A Covid WMS layer can be shown or hide from map using helper function available.

A Covid WMS layer can be shown on map by calling a function showInteractiveLayerOnMapForLayerId. This function accepts a string value which must be layerId of one of object from list of interactive layers.

Objective-C
[self.mapView showInteractiveLayerOnMapForLayerId:@"pass-unique-layerId-here"];
Swift
mapView.showInteractiveLayerOnMap(forLayerId: "pass-unique-layerId-here")

A Covid WMS layer can be hide from map by calling a function hideInteractiveLayerFromMapForLayerId. This function accepts a string value which must be layerId of one of object from list of interactive layers.

Objective-C
[self.mapView hideInteractiveLayerFromMapForLayerId:@"pass-unique-layerId-here"];
Swift
mapView.hideInteractiveLayerFromMap(forLayerId: "pass-unique-layerId-here")

On tap on Map object covid related information for visible codvid layers will we fetched from server.

Information from top visible covid layer, will be received in delegate method didDetectCovidInfo, which is part of MapplsMapViewDelegate protocol class.

didDetectCovidInfo delegate methods will return an object of MapplsCovidInfo class which can be used to display different information. It will return nil if no info exists.

Objective-C
- (void)didDetectCovidInfo:(MapplsCovidInfo *)covidInfo
{
    if (covidInfo) {
    }
}
Swift
func didDetect(_ covidInfo: MapplsCovidInfo?) {
    if let covidInfo = covidInfo {
    }
}

A marker at tapped location can be plotted on map after succesfully query covid related WMS layers.

Marker can be allowed or disallowed to plot on map by setting value of boolean property shouldShowPopupForInteractiveLayer. To allow to show marker set its value to true. By default it is false, means no marker shows on tap of covid WMS Layers.

Below is code for refrence to create a toggle button to enable or disable Covid Marker:

Objective-C
- (IBAction)covidMarkerToggleButtonPressed:(UIButton *)sender {
    BOOL newState = !_covidMarkerToggleButton.isSelected;
    [_covidMarkerToggleButton setSelected:newState];
    [_mapView setShouldShowPopupForInteractiveLayer:newState];
}
Swift
@IBAction func covidMarkerToggleButtonPressed(_ sender: UIButton) {
    let newState = !sender.isSelected;
    covidMarkerToggleButton.isSelected = newState
    self.mapView.shouldShowPopupForInteractiveLayer = newState
}

A Mappls's map component which is part of MapplsMap SDK for iOS.




Our many happy customers:


For any queries and support, please contact:

Email us at apisupport@mappls.com

Support Need support? contact us!



@ Copyright 2022 CE Info Systems Pvt. Ltd. All Rights Reserved.