Procedural GL JS 是一个用于在网络上创建 3D map体验的库,用 JavaScript 和 WebGL 编写。它建立在THREE.js 之上。
它提供了一个易于使用但功能强大的框架,可以将美丽的户外风景嵌入到网页中。它加载速度超快,并针对移动设备进行了优化。
npm install procedural-gl
import Procedural from 'procedural-gl';
// Choose a DOM element into which the library should render
const container = document.getElementById( 'container' );
// Configure datasources
const datasource = {
provider: 'maptiler',
// To get a free key, use https://cloud.maptiler.com/account/?ref=procedural
apiKey: 'GET_AN_API_KEY_FROM_MAPTILER'
};
// Initialize library and optionally add UI controls
Procedural.init( { container, datasource } );
Procedural.setRotationControlVisible( true );
// Load real-world location
const montBlanc = { latitude: 45.8326364, longitude: 6.8564201 };
Procedural.displayLocation( montBlanc );
要使用库实际加载数据,你需要连接到数据源。进行设置的最快方法是在MapTiler上注册一个免费帐户,然后使用如上所示的 API 密钥。
有关设置数据源的详细说明,请参阅 wiki 中的此页面
如果这个库对你有用,请考虑赞助该项目。
Procedural GL JS 根据Mozilla Public License Version 2.0获得许可。