Map
创建一个 map 实例.
Parameters
名字 | 描述 |
---|---|
center | 可选项 定义map视图的初始中心。例子: { lat: 28.6139, lng: 77.209 } 默认值: {lat: 28.5934, lng: 77.2223} |
zoom | 可选项 定义map视图的初始缩放等级。例子:12 默认值: 12 |
theme | 可选项 定义地图视图的初始主题,目前支持dark 和light .默认值: 'light' |
vectorTilesSourceUrl | 可选项 定义初始矢量瓦片的源URL,你可以使用第三方或自定义的瓦片服务来渲染地图。例子: vectorTilesSourceUrl: 'https://example.com/your-source.json' 默认值: NextBillion.ai Maps built-in tiles service |
方法
设置主题
切换一个map实例的主题。
1setTheme(name: string)
例子
1var map = new nextbillion.maps.Map(document.getElementById('map'), {
2 zoom: 12,
3 center: { lat: 28.6139, lng: 77.239 },
4 theme: 'light',
5 vectorTilesSourceUrl: 'https://example.com/your-source.json',
6})
7
8// 切换主题
9map.setTheme('dark')
设置矢量瓦片的源
为一个map实例设置矢量瓦片源。
1setSource(url: string)
例子
1var map = new nextbillion.maps.Map(document.getElementById('map'), {
2 zoom: 12,
3 center: { lat: 28.6139, lng: 77.239 },
4 theme: 'light',
5 vectorTilesSourceUrl: 'https://example.com/your-source.json',
6})
7
8// 设置矢量瓦片的源
9map.setSource('https://example.com/alternative-source.json')
转场(fly to)
通过动画过渡呈现不同位置、缩放级别、方位或间距切换过程。
1map.flyTo(options)
Example
1var map = new nextbillion.maps.Map(document.getElementById('map'), {
2 zoom: 12,
3 center: { lat: 28.6139, lng: 77.239 },
4})
5
6map.flyTo({
7 center: { lat: 36.0671, lng: 120.3826 },
8 zoom: 16,
9 speed: 1.5,
10 curve: 0.8,
11})
Circle
Marker