2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt odlux
4 * =================================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
19 import * as mapboxgl from 'mapbox-gl';
20 import apartment from '../../icons/apartment.png';
21 import datacenter from '../../icons/datacenter.png';
22 import factory from '../../icons/factory.png';
23 import lamp from '../../icons/lamp.png';
24 import datacenterred from '../../icons/datacenterred.png';
25 import factoryred from '../../icons/factoryred.png';
26 import lampred from '../../icons/lampred.png';
29 type ImagesLoaded = (allImagesLoaded: boolean) => void;
30 type MapImages = {name: string, url: string}
32 export const Images : MapImages[] = [
33 {name: 'data-center', url: datacenter},
34 {name: 'house', url: apartment},
35 {name: 'factory', url: factory},
36 {name: 'lamp', url: lamp},
37 {name: 'data-center-red', url: datacenterred},
38 {name: 'factory-red', url: factoryred},
39 {name: 'lamp-red', url: lampred},
42 export const addImages = (map: mapboxgl.Map, callback?: ImagesLoaded) =>{
44 Images.forEach(image => {
48 function (error: any, img: any) {
49 if (error) throw error;
50 map.addImage(image.name, img);
51 allImagesLoaded(map, callback);
56 const allImagesLoaded = (map: mapboxgl.Map, callback?: ImagesLoaded) =>{
58 const loadedImages = Images.map(image =>{
59 return map.hasImage(image.name);
62 const allImagesLoaded = loadedImages.filter(el => !el);
63 if(allImagesLoaded.length===0){
64 callback && callback(true);