|
POST
|
Found a good enough workaround, if you call window.location.reload() inside ngOnDestroy of any page that hosts the maps, the memory will be freed, which is what we're doing.
... View more
08-26-2020
09:57 AM
|
0
|
1
|
4535
|
|
POST
|
Good Afternoon I'll give this a try and let you know how it works.
... View more
08-13-2020
11:53 AM
|
0
|
0
|
4535
|
|
POST
|
Good Day Solid name Do you have an example of how to use a service to maintain the same view across several maps? I wrote this function, which lives in a service (esri-service.ts), which is separate from the esri-map-controller.ts: initMap(mapContainer: ElementRef) {
return new Promise( (r, j) => {
loadModules([
'esri/Map',
'esri/views/MapView',
]).then(([
EsriMap,
EsriMapView,
]) => {
if (this._map === null && this._view === null) {
console.log('\n\nAllocating new Map!!!\n\n');
const mapProperties: esri.MapProperties = {
basemap: this._basemap,
};
this._map = new EsriMap(mapProperties);
const mapViewProperties: esri.MapViewProperties = {
container: mapContainer.nativeElement,
center: this._center,
zoom: this._zoom,
map: this._map
};
this._view = new EsriMapView(mapViewProperties);
r({
map: this._map,
view: this._view
});
} else {
console.log('\n\nUsing Existing!!!\n\n');
const reAllocateMap = false;
if (reAllocateMap) {
const mapProperties: esri.MapProperties = {
basemap: this._basemap,
};
this._map = new EsriMap(mapProperties);
this._view.map = this._map;
}
this._view.container = mapContainer.nativeElement;
r({
map: this._map,
view: this._view
});
}
});
})
} The first time I call this I get a map and view and everything works fine, but when I call it a second time to get the view, then swap the ElementRef, the map appears but I can't interact with it. If I change the code and allocate a new map object then assign it into the view, I get a fully interactive view and map back, but the memory usage goes way up again, which is the problem I'm trying to work around. When I look at the detached memory, I see a bunch of references to MapView.js and engine.js from an arcgis 4.15 / 4.14 url, which I think is coming from EsriMapView and EsriMap, but I can't do anything with them except set them to null in the ngOnDestroy, because if I try to call .destroy() an exception is thrown that the function doesn't exist. Could there be an issue with EsriMapView getting properly destroyed? If you reference the sample project I made, it has this same issue, and I noticed the same problem on the angular-cli-map project.
... View more
08-12-2020
03:19 PM
|
0
|
4
|
4535
|
|
POST
|
This is still an issue, if we navigate away from the maps the memory isn't getting free'd, it looks like the MapView isn't destroying itself properly.
... View more
08-12-2020
02:52 PM
|
1
|
7
|
5529
|
|
POST
|
Good Day I've noticed a memory issue where, at least in Angular 9, once your destroy the view / map objects, the memory usage is extremely high, ~100 MB / map. I’ve Prepared a test repo, that initializes a map and allows you to jump to another page, when I run this code and jump between the pages the memory isn't being freed correctly, hopefully this helps: GitHub - docmur/angular-esri-memory-test My destroy functions, of our main application is: nullifyComponents() {
console.log('Destroying the ESRI View and ESRI Map');
if (this._map) {
this._map.removeAll();
this._map.destroy();
this._map = null;
delete this._map;
} else {
console.log('Map is NULL');
}
if (this._view) {
this._view.map = null;
this._view.container = null;
this._view.destroy();
this._view = null;
delete this._view;
} else {
console.log('View is NULL');
}
this._BasemapGallery.destroy();
this._BasemapGallery = null;
this.EsriMap = null;
this.EsriMapView = null;
this.FeatureLayer = null;
this.SimpleMarkerSymbol = null;
this.SimpleFillSymbol = null;
this.SimpleLineSymbol = null;
this.Color = null;
this.Graphic = null;
this.WatchUtil = null;
this.BasemapGallery = null;
this.Home = null;
this.Expand = null;
this.Print = null;
this.PrintTask = null;
this.PrintTemplate = null;
this.PrintParameters = null;
this._BasemapGallery = null;
}
removeByTag(tag) {
const element = document.getElementById(tag);
while (element[0]) {
element[0].parentNode.removeChild(element[0])
}
}
@HostListener('window:beforeunload')
async ngOnDestroy() {
try {
/* Get rid over everything else */
this.removeAll();
/* Destroy and remove memory references to the maps */
this.nullifyComponents();
this.mapViewEl = null;
delete this.mapViewEl;
this.removeByTag('mapElement');
} catch (error) {
console.log(error);
}
} When I look at the memory tab I see: When I run a heap stack trace I see: Among another objects. Is there another way to assure the memory is getting freed? If I navigate back to the maps and away, it will add another 100 MB / map, until all the memory is used up. The function removeAll is setting all internal variables to null to assure they don't reference any of the ESRI components. The version of the library in use is 4.14. I’ve tried everything I can think of to free the memory including deleting the DOM elements in ngOnDestroy, and after they’re removed, the memory still remains. I've seen this across Windows, Linux and Firefox / Chromium based browsers. Thanks
... View more
08-10-2020
08:10 AM
|
0
|
7
|
4802
|
|
POST
|
I was mistaken we're using 4.14, can someone from ESRI look into this and please update us?
... View more
08-07-2020
09:18 AM
|
0
|
0
|
1248
|
|
POST
|
Prepared a test repo, that initializes a map and allows you to jump to another page, when I run this code and jump between the pages the memory isn't being freed correctly, hopefully this helps: GitHub - docmur/angular-esri-memory-test
... View more
08-05-2020
08:13 AM
|
0
|
0
|
1248
|
|
POST
|
Good Day We have a map with thousands of small polylines and as we change the zoom level the lines appear when we zoom in and disappear when we zoom out, is there a way to prevent this functionality? Can we have them render like markers, where zoomed out we just see one large marker? This is our Feature Layer / Render Build code:
buildFeatureSettings(geometryType, data, colour) {
console.log('Feature Layer Data');
console.log(data);
return {
source: data,
renderer: this.buildRenderSettings(data, colour, geometryType.toString().includes('point')),
fields: this._fields,
objectIdField: 'ObjectID',
geometryType: geometryType,
spatialReference: {
wkid: 4326
},
title: this._allAssets ? data[0].attributes.assetType : data[0].attributes.layer
};
}
/**
* Build the rendering options for the feature layer
*/
buildRenderSettings(data, colour: string, marker = false) {
return {
type: 'simple',
symbol: {
style: marker ? 'circle' : null,
type: marker ? 'simple-marker' : 'simple-fill',
size: marker ? 12 : 30,
color: _.cloneDeep(colour),
outline: {
width: 4,
color: _.cloneDeep(colour),
}
},
}
} Thanks
... View more
07-30-2020
03:00 PM
|
1
|
0
|
963
|
|
POST
|
Good Day (Editing to push back up the forum) I integrated a print template to capture the maps in our software. When I capture polylines they render without colour, but if I capture points, they render just fine, is there something I have to set when building the polylines to in order for the capture to grab the colour? I've attached some sample captures showing the difference: The legend / feature layer information at the bottom is correct, with the correct name and colour being shown, so I don't think this is a feature layer issue, this is my print template code, and I've tried using PDF, it renders the same way; printMap() {
const usePrintTask = true;
if (usePrintTask) {
const printTask = this.PrintTask({
url: 'https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task'
});
const template = new this.PrintTemplate({
format: 'jpg',
layout: 'a4-landscape',
layoutOptions: {
titleText: 'DOT ESRI Map',
authorText: 'Infrasol'
}
});
const params = new this.PrintParameters({
view: this._view,
template: template
});
printTask.execute(params).then(this.printResult, this.printError);
} else {
this._view.takeScreenshot().then( (res) => {
console.log('Res');
console.log(res);
const w = window.open('about:blank');
const image = new Image();
image.src = res.dataUrl;
setTimeout(() => {
w.document.write(image.outerHTML);
}, 0);
});
}
} printResult(result) {
console.log('Result');
console.log(result);
console.log(result.url);
window.open(result.url);
}
printError(err) {
console.log('ESRI Print Task Error: ', err);
} Have I done anything clearly wrong? Thanks
... View more
07-28-2020
09:50 AM
|
0
|
8
|
3821
|
|
POST
|
Thanks for the assistance, and especially thanks for the code sample! I was having problems finding documentation related to yesterday, but I'll implement you ideas.
... View more
07-23-2020
10:38 AM
|
1
|
0
|
7530
|
|
POST
|
Good Day Without using the Print Widget, is there a way to print the current map view? I was thinking about converting the map to a canvas or SVG and then sending that to a new tab, and calling window.print(). I tried playing with this idea yesterday, but couldn't get it to work, ideally we want a small button on the map that looks like the other widget buttons. Thanks
... View more
07-23-2020
09:39 AM
|
0
|
6
|
7653
|
|
POST
|
We haven't ran into this for the last few days, if we do I'll try to log it.
... View more
07-23-2020
09:37 AM
|
0
|
21
|
3148
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-25-2025 07:33 AM | |
| 1 | 03-18-2025 11:15 AM | |
| 1 | 10-07-2022 08:14 AM | |
| 1 | 08-25-2023 10:47 AM | |
| 1 | 02-23-2023 08:22 AM |
| Online Status |
Offline
|
| Date Last Visited |
03-13-2026
07:55 AM
|