Skip to content

Commit

Permalink
Merge pull request #199 from LYF720/master
Browse files Browse the repository at this point in the history
高德2.0版本适配
  • Loading branch information
sakitam-fdd authored Feb 29, 2024
2 parents 846ad79 + 7f3d51a commit 3703c0e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/amap.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/build/dat.gui.css">
<script src="http://webapi.amap.com/maps?v=1.4.2&key=6cb85da518029607d421917b7ddeb94a"></script>
<script src="http://webapi.amap.com/maps?v=2.0&key=6cb85da518029607d421917b7ddeb94a"></script>
<style>
html, body, #map {
height: 100%;
Expand Down
2 changes: 1 addition & 1 deletion examples/mapbox-tile.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@
});
</script>
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion examples/maptalks-particles-layer.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@
// map.addLayer(layer);
</script>
</body>
</html>
</html>
15 changes: 3 additions & 12 deletions packages/amap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,9 @@ class AMapWind {
const type = this.map.getViewMode_();
let [southWest, northEast] = [undefined, undefined];
const bounds = this.map.getBounds();
if (type.toLowerCase() === '2d') {
northEast = bounds.getNorthEast(); // xmax ymax
southWest = bounds.getSouthWest(); // xmin ymin
} else {
// TODO: 高德地图3D模式下目前返回的bounds顺序为左上-右上-右下-左下-左上
const arrays = bounds.bounds.map((item: any) => {
return [item.getLng(), item.getLat()];
});
// const extent = getExtent(arrays);
southWest = new AMap.LngLat(arrays[3][0], arrays[3][1]);
northEast = new AMap.LngLat(arrays[1][0], arrays[1][1]);
}
// FIX: 高德地图3D模式和2D模式,map.getBounds接口已统一
northEast = bounds.getNorthEast(); // xmax ymax
southWest = bounds.getSouthWest(); // xmin ymin
return new AMap.Bounds(southWest, northEast);
}

Expand Down

0 comments on commit 3703c0e

Please sign in to comment.