all files / components/popupOpener/ popupOpener.controller.js

4.35% Statements 1/23
0% Branches 0/8
0% Functions 0/7
4.35% Lines 1/23
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51                                                                                                    
angular.module('webmapp')
 
    .controller('PopupOpenerController', function PopupOpenerController(
        $ionicPlatform,
        $state,
        MapService,
        Utils
    ) {
        var id = $state.params.id,
            zoom = null;
 
        if ($state.params.zoom) {
            zoom = $state.params.zoom;
        }
 
        $ionicPlatform.ready(function () {
            setTimeout(function() {
                var timerFunction = function () {
                    if (MapService.isReady()) {
                        var features = MapService.getFeatureIdMap();
 
                        setTimeout(function () {
                            if (features[id]) {
                                MapService.centerOnFeature(features[id]);
                                MapService.setFilter(features[id].parent.label, true);
                                if (zoom) {
                                    setTimeout(function () {
                                        MapService.setZoom(zoom);
                                    }, 100);
                                }
 
                                setTimeout(function () {
                                    MapService.triggerFeatureClick(id);
                                }, 250);
                            }
                        }, 250);
                    } else {
                        setTimeout(timerFunction, 300);
                    }
                };
 
                timerFunction();
 
                MapService.resetView();
                Utils.goTo('/')
            }, 1000);
        });
 
        return {};
    });