Forum Discussion
Could not load image because of out of range source coordinates for image copy.
I use the azure-maps-control SDK version 2.3.7 for my Angular app. When I Initialise the Map it intermittently fires the error event. So sometimes it fires when the map loads and sometimes it does not. The error fires before I add any markers to the map, but Also if I remove all my code to add markers to the map and simply initialise the map. So if the error event fires the message I receive is: "Could not load image because of out of range source coordinates for image copy. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."
I use the Angular ngAfterViewInit lifecycle hook to initialise the map and the AzureMapsModule.forRoot to set the authOptions
ngAfterViewInit(): void {
this._initMap();
}
private _initMap() {
this._map = new atlas.Map(this.mapId, {
language: 'en-us',
style: 'satellite',
showFeedbackLink: false,
});
this._map.events.add('ready', (event) => {
this._map$.next(event.map);
this.map.emit(this._map$.asObservable());
});
this._map.events.add('error', (e) => {
console.error(e);
this._sharedService.showMessage(
'Error occurred while loading the map',
SnackBarClasses.error,
);
});
this._map$.next(this._map);
}
AzureMapsModule.forRoot({
authOptions: {
authType: AuthenticationType.subscriptionKey,
subscriptionKey: environment.azureMapsSubscriptionKey,
},
}),
1 Reply
Some workarounds that are worth to try:
- Upgrade to a Newer SDK Version
If possible, upgrade to the latest stable version of the Azure Maps SDK. Newer versions (e.g., v3.x) include bug fixes for image handling and rendering issues.
- Use a Different Map Style Temporarily
Try switching from 'satellite' to 'road' or 'grayscale_dark' to see if the error persists. Some styles may have different internal asset requirements.
style: 'road', // instead of 'satellite'
- Delay Initialization Slightly
Sometimes the map container isn't fully rendered when ngAfterViewInit fires. Try wrapping _initMap() in a setTimeout or using requestAnimationFrame to delay initialization:
ngAfterViewInit(): void { setTimeout(() => this._initMap(), 0); }
- Check for Container Size
Ensure the map container has a valid size before initializing. A zero-width or height container can cause rendering errors.