Skip to content

Map Not getting refreshed after changing dynamic map profile #1182

@sreedeeplal

Description

@sreedeeplal

I would like to set map profile dynamically out of the map components.
Step 1- I created the map profile in our xserver - Success
Step 2 - Getting the profile Db successfully - Success

Step 3 - I injected the new profile value into existing defined layers, value changes but the map is not getting refreshed.

Please verify the code

$scope.getMapProfile = getMapProfile;

    $scope.getMapProfile();
    function getMapProfile() {
        apiService.get('/api/mapprofile/getmapprofile', $scope.data,
         getMapProfileSucceded,
        getMapProfileFailed);
    }

    function getMapProfileSucceded(result) {

        if (result.data != null) {
            mapprofile = result.data.Profile;
        }
    
     $scope.definedLayers.ptvclassic.url = mapUrl + 'services/rest/XMap/tile/{z}/{x}/{y}?size={tileSize}&storedProfile=' + mapprofile;
     $scope.layers.baselayers.ptvclassic = $scope.definedLayers.ptvclassic;
     leafletData.getMap().then(function (map) {
         setTimeout(function () {
             map.invalidateSize();// invalidateSize show undefind 
             map._resetView(map.getCenter(), map.getZoom(), true);
         }, 200);
     });
    }`

`$scope.definedLayers = {
ptvclassic: {
name: 'PTV xMap Classic',
url: mapUrl + 'services/rest/XMap/tile/{z}/{x}/{y}?size={tileSize}&storedProfile=' + mapprofile,

            type: 'xyz',
            layerOptions: {
                showOnSelector: true,
                minZoom: 3,
                maxZoom: 19,
                opacity: 1
            }
        }

};
`

` angular.extend($scope, {
center: {
lat: 49.42855,
lng: 9.42181,
zoom: $scope.zoomLevel
},
defaults: { maxZoom: 17, zoomAnimation: false, fadeAnimation: false, zoomControl: false },
events: {

        },
        controls: {
            custom: [customZoom, focusOnSelectCtrl],
            draw: {
                draw: {
                    polyline: false,
                    marker: false
                }
            },
            scale: { position: "bottomleft" }
        },
        layers: {
            baselayers: {
                ptvclassic: $scope.definedLayers.ptvclassic
               
            }
            
        }
    });`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions