Map iframe-based integration

This demo-document describes the iframe-based integration of the map.
It is a technical document dedicated to technical audience.

The iFrane connector:

Create the map integrator object to connect the map to an existing div element.
The instance creation takes 2 arguments: the element id where to insert the map and some options (see below)
<div id="container" style="background-color: #555555;">

<script>
    window.amapi = new AMapIntegrator(
        "container", // div element id to integrate the iframe
        {
            // baseUrl: cdn media cache base url: we provide this url
            baseUrl: "https://cdn-server-host",

            // api_key: we provide the api key
            apiKey: "aaaaaabbbbbccccc",

            // site code: we provide the site code
            siteCode: "XXXX",

            // lang: Code of one of the languages available in the project.
            // Default value: "EN"
            lang: "EN",

            // baseui: show (true) or hide (false) levels and zoom buttons.
            // On touch-enabled devices, the zoom-in and zoom-out buttons are hidden
            // Default value: true
            baseui: true,

            // useMobileModels: on some projects we can have different mobile 3D models for mobile than for kiosks.
            // Lighter/simpler models for example. Set this option to true to use the mobile models
            // Default value : true
            useMobileModels: true,

            // lazyld: Depending on the project, some 3D models may take time to load (size, textures,...),
            // set this option to true to enable lazy loading. When enabled the 3D models for a zone (floor) are loaded
            // when the zone is first shown/selected. In any case, the map 3D models are loaded once per session.
            // For small projects, it is better to set this option to false to avoid the small loading halt on zone's first show/select.
            // Default value : false
            lazyld: false,

            // noCacheDisabled: value = true disables the hint to avoid browser caching of site payloads (data, geometry).
            // Default value : false
            noCacheDisabled: false,

            // searchFeature: value = true show a search autocomplete field to search for POIs by name or cell-id.
            // Type some text and hit enter. (max search results is set to 20)
            // Default value : false
            searchFeature: true,

            // searchCellId: value = false disable search cell-id (just by name).
            // Default value : true
            searchCellId: true,

            // hover: value = true enable the MouseHOver events.
            // When enabled and the user move the mouse (without pushing any button) over a POI, that POI is hightlighted and pin-point shown.
            // There's also a public API to do the same via javascript: setHoverEnabled (see below)
            // Default value : false
            hover: false,

            // zonesDropdown: value = true use a Drop-down menu for the map zones (levels) instead of showing the full list.
            // Default value : false
            zonesDropdown: false,

            // hideZonesMenu: if value = true the map zones (levels) menu is not generated.
            // Default value : false
            hideZonesMenu: false,

            // mapSelect: if value = false the selection by clicking on the map is disabled.
            // Default value : true
            mapSelect: true,

            // callback when User clicks directly on a POI on the map
            onClickOnPoi: function (data) {
                console.log("Integrator: POI= ", data);
            },

            // callback when all data is loaded
            onMapLoaded: function () {
                console.log("Integrator: Map loaded");
            },

            // callback when User resets the map using the zoom-reset button
            onReset: function () {
                console.log("IntegratorL: Reset");
            }
        });
</script>

The APIs:

Using the integrator object created above (amapi), the hosting app can manipulate the map using the following APIs.

All communications are based on the POI geoId (geometrical ID) or cellId (example: mall leasing area Id). Each POI is connected to a physical surface via these ids.
The geometrical IDs are automatically generated by the geometry itself, whilst the cell-ids are business ids and can be manually filled/attached to areas on our CMS

The hosting App is supposed to load the Site data (information and urls are provided)

Hosting app to Map APIs:

The below APIs allow the hosting app to control and interact with the map loaded in the iframe element.
Click on the links below to test the APIs.

Select POI by cell-id or geoId:
window.amapi.selectPoi("_44498_35709_0")
Select Services by service type code:
window.amapi.selectServiceByCode("toilets_male")
Select a zone by zone index (0 ... nb zones - 1). Param 2 to use animation or not:
window.amapi.focusOnZone(0, true)
Clear Selection:
window.amapi.clearSelection()
Show path between 2 nodes represented by cellId/geoId. Parameter 3 is a boolean for LIFT route, Parameter 4 is a boolean to start path animation (true) or not (false)
window.amapi.showPath("_49302_14941_0", "_44498_35709_0", false, false)
Show Path with animation:
window.amapi.showPath("_49302_14941_0", "_44498_35709_0", false, true)
Reset Map and clear all:
window.amapi.reset()
Set default view using camPos [x,y,z]), scenePos ([x,y,z]
and zoneIndex (0...nbZones-1) optional.
if zoneIndex is null, undefined or not provided, the default view will be set globally.
if zoneIndex is a valid index, the default view will be set to that zone only.
window.amapi.setDefaultView([50919, 68138, 45812], [43116, 35864, 300]); window.amapi.reset();
Enable, Disable MouseOver:
window.amapi.setHoverEnabled(true);
window.amapi.setHoverEnabled(false);
Get Current Map view parameters.
This will popup a message with the camera position and the scene position currently used in the map projection
window.amapi.getCurrentView();
Update some POI data (color, subtitle) from custom payload:

The subtitle is shown under the POI title. It can be in html format.

window.amapi.updateFromCustomData({
pois: [
{ id: "G-500", color: [1,1,0,1], subTitle: "<p>Hello!</p>"},
{ id: "M004", color: [1,1,0,1], subTitle: "<p>World!</p>"}
]
});
Set POIs default color:
This will set the extrusion color for ALL the POIs on the map
The parameter is and array of 3 or 4 decimal values 0...1 : [r, g, b, a]
a is the opacity (optional, default = 1)
window.amapi.setPoiDefaultColor([1,0.5,0,1]);
Set POI label color:
This will set the POI label (text or logo) color for ALL the POIs on the map
The parameter is and array of 3 or 4 decimal values 0...1 : [r, g, b, a]
a is the opacity (optional, default = 1)
window.amapi.setPoiLabelColor([1,1,0,1]);
Set Zones model color:
This will set the 3D surfaces color and textures tones (diffuse color) for ALL the zones decoration 3D models on the map.
It does NOT affect the POIs extrusion color
The parameter is and array of 3 or 4 decimal values 0...1 : [r, g, b, a]
a is the opacity (optional, default = 1)
window.amapi.setZoneModelColor([0,0.5,1,1]);

Map to hosting app APIs:

As shown the code sinppet above, the Integrator constructor defines 3 callbacks from the Map (loaded in the iframe element) toward the hosting app.

This allows the hosting app to react to some of the user's interactions on the map.