Skip to content

Commit b1ec6c8

Browse files
committed
fix:优化海图示例:ol初始级别,maplibregl加载图片失败
1 parent 43fce0a commit b1ec6c8

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎examples/maplibregl/01_chartService.html‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -875,11 +875,18 @@
875875
'filter': ['==', '$type', 'Point']
876876
});
877877
}
878-
map.loadImage(
879-
'../img/point2.png',
880-
function(error, image) {
881-
if (error) throw error;
882-
map.addImage('icon_name', image);
878+
map.on('load', function() {
879+
// maplibre-gl v3版本用法:
880+
// map.loadImage('../img/point2.png', function(error, image) {
881+
// if (error) throw error;
882+
// map.addImage('icon_name', image);
883+
// });
884+
// maplibre-gl v4及以上版本用法:
885+
map.loadImage('../img/point2.png').then(function(image) {
886+
map.addImage('icon_name', image.data);
887+
}).catch(function(error) {
888+
console.error('Failed to load point2.png:', error);
889+
});
883890
});
884891

885892
function sqlQuery() {

‎examples/openlayers/01_chartService.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@
411411
})]),
412412
view: new ol.View({
413413
center: [60.93, -32.53],
414-
zoom: 13,
414+
zoom: 14,
415415
projection: 'EPSG:4326',
416416
multiWorld: true
417417
}),

0 commit comments

Comments
 (0)