NGview中使用AngularJS的ArcGis API不会启动ArcGis API事件

时间:2016-04-18 12:35:04

标签: javascript angularjs arcgis ngroute arcgis-js-api

我的ArcGis和Angular的应用程序运行完美,但是当我尝试引入角度路由并将ArcGis API代码移动到另一个将加载ng-view的div时,Arcgis事件似乎不再激活。 / p>

路线:

$routeProvider
    .when('/index/:contextId', {
        templateUrl: 'dist/geoClick.html',
        controller: 'GeoClickController',
        label: 'GeoClick',
        resolve: {
            data: function ($route, $location, authorizationService) {
                if (!authorizationService.isContextIdValid($route.current.params.contextId)) {
                    $location.path('/notAllowed');
                }
            }
        }
    })
    .when('/notAllowed', {
        templateUrl: 'dist/notAllowed.html',
        label: 'notAllowed'
    })

的MainPage:

app.controller('GeoClickController', function ($scope, $http, $window, $location, proxyService) {
var map;
var toolbar;

require(['esri/map', 'esri/layers/ArcGISDynamicMapServiceLayer', 'esri/SpatialReference', 'esri/geometry/Extent',
    'esri/symbols/SimpleMarkerSymbol', 'esri/symbols/SimpleLineSymbol', 'esri/symbols/SimpleFillSymbol', 'esri/symbols/PictureMarkerSymbol', 'esri/toolbars/draw',
    'esri/graphic'],
    function (Map, ArcGISDynamicMapServiceLayer, SpatialReference, Extent,
    SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, PictureMarkerSymbol, Draw, Graphic) {
        map = new Map('mapDiv', {
            extent: new esri.geometry.Extent({
                'xmin': 20000,
                'ymin': 150000,
                'xmax': 245000,
                'ymax': 265000,
                'spatialReference': {
                    'wkid': 31370
                }
            }),
            slider: true
        });
        var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer('http://prod461/ArcGIS/rest/services/Ref_MultinetBW_L72_FGDB/MapServer', {
            'opacity': 1
        });

        map.addLayer(dynamicMapServiceLayer);



        map.on('load', createDrawingToolbar);

        function createDrawingToolbar() {
            map.graphics.clear();
            toolbar = new Draw(map);
            toolbar.markerSymbol = new PictureMarkerSymbol("Images/marker.png", 32, 64);
            toolbar.on("draw-end", selectPoint);
        }

        function selectPoint(evt) {
            map.graphics.clear();
            var symbol;
            switch ($scope.drawingMode) {
                case "point":
                case "multipoint":
                    symbol = new PictureMarkerSymbol("Images/marker.png", 32, 64);
                    break;
                case "polyline":
                    symbol = new SimpleLineSymbol();
                    break;
                default:
                    symbol = new SimpleFillSymbol();
                    break;
            }
            latestGraphic = new Graphic(evt.geometry, symbol);
            map.graphics.add(latestGraphic);
            showSaveButtonIfNecessary();
            $scope.deactivateDrawingMode();
        }

});});

Html只是一个主页面,侧面页面包含它们代表的ngControllers

0 个答案:

没有答案