问题描述
以下“竖琴”示例使用屏幕位置和某些“未知”度量单位将多边形添加到地图。如何根据多边形的形状/高度和以米为单位的高度添加多边形?
//Create the three.js cube
const geometry = new THREE.BoxGeometry(100,100,100);
const material = new THREE.MeshStandardMaterial({ color: 0x00ff00fe });
const cube = new THREE.Mesh(geometry,material);
cube.renderOrder = 100000;
//Get the position of the click
const geoPosition = map.getGeoCoordinatesAt(evt.pageX,evt.pageY);
cube.geoPosition = geoPosition;
//Add object to the map
map.mapAnchors.add(cube);
map.update();
解决方法
mapAnchors API用于向地图中添加three.js对象。
如果您要添加地理多边形,则可以通过GeoJSON或FeatureDataSource(实际上只是在geojson之上的便捷包装)来实现。
请参阅以下示例: