
Security News
MCP Steering Committee Launches Official MCP Registry in Preview
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
@baidumap/mapv-three
Advanced tools
JSAPI Three 是由百度地图开放平台推出的基于 WebGL 的下一代二三维一体化地图引擎,帮助开发者快速搭建自己的二三维地图场景。JSAPI Three 采用mapvthree
作为命名空间,基于 Three.js 158 版本开发,采用 Three.js 作为底层渲染引擎。
官网:https://lbsyun.baidu.com/faq/api?title=jsapithree
示例中心:https://lbsyun.baidu.com/jsapithree/tutorial
类参考:https://lbsyun.baidu.com/jsapithree/docs/modules/mapvthree.html
mapvthree 基于 Three.js 158 版本开发,采用 Three.js 作为底层渲染引擎。请执行以下命令安装必要的依赖:
npm i -S @baidumap/mapv-three three@0.158.0
mapvthree 在初始化时需要加载必要的静态资源。如果在未完成配置的情况下运行 npm run dev
,您可能会遇到以下错误提示:
<p style={{color: '#f00'}}>"Unable to determine base URL automatically, try defining a global variable called MAPV_BASE_URL."</p>
此错误表明引擎无法正确访问所需的静态资源。您需要配置构建工具,将 mapvthree 的静态资源复制到项目的打包目录中。
如果您使用 Webpack 作为构建工具,请参考以下配置:
// webpack.config.js
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpackConfig = {
...
plugins: [
new CopyWebpackPlugin({
patterns: [
{from: 'node_modules/@baidumap/mapv-three/dist/assets', to: 'mapvthree/assets'},
],
}),
...otherPlugins,
]
...
};
如果您使用 Vite 或 Rollup 作为构建工具,请参考以下配置:
// vite.config.js
import copy from 'rollup-plugin-copy';
const viteConfig = {
...
plugins: [
copy({
targets: [
{src: 'node_modules/@baidumap/mapv-three/dist/assets', dest: 'public/mapvthree'},
],
// vite需要加下面这两这个参数,rollup可忽略
verbose: true,
hook: 'buildStart',
}),
...otherPlugins,
]
...
};
完成构建工具配置后,请在项目的 index.html
模板中声明 MAPV_BASE_URL
全局变量,指向静态资源目录:
<!-- index.html -->
<script>
window.MAPV_BASE_URL = 'mapvthree/'; // 配置为mapv-three包路径的dist目录
</script>
mapvthree 默认展示百度地图矢量数据,使用前需要配置百度地图开发者密钥(AK)。请按照以下步骤操作:
获取 AK 后,您需要在项目的入口处进行配置,以下配置全局执行一次即可:
// 在项目入口文件中配置
import * as mapvthree from '@baidumap/mapv-three';
// 配置百度地图 AK
mapvthree.BaiduMapConfig.ak = '您的AK密钥';
完成上述配置后,您即可开始使用 mapvthree 进行开发。
FAQs
A powerful 3D map engine.
We found that @baidumap/mapv-three demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.