跳到主要内容
版本:9.14.0-beta

苏州 2000 支持

苏州 2000 支持扩展,同时支持苏州 2000 矢量服务、苏州 2000 栅格服务、苏州 2000 GeoJSON 数据、苏州 2000 三维模型和 3DTiles 服务加载。

苏州 2000 坐标转换​

Mapmost SDK for WebGL 仅支持 SDK 坐标的输入输出,对于苏州 2000 坐标数据,提供苏州 2000 坐标与 SDK 坐标转换工具。

用法​

苏州 2000 转 SDK 坐标接口:

mapmost.Convert.fromDefinedProj();

SDK 坐标转苏州 2000 接口:

mapmost.Convert.toDefinedProj();

案例​

//SDK中心点坐标计算
let center = mapmost.Convert.fromDefinedProj([342171.097900000400841, 665836.627800000831485]);
//地图初始化
let map = new mapmost.Map({
container: "map", // 地图容器 id
style: "http://******/mms-style/color_pub_suzhou2000.json", //sz2000 样式文件
center: center, // 地图初始中心点坐标
zoom: 13, // 地图初始缩放层级
pitch: 60, // 地图初始俯仰角
bearing: 0, // 地图初始方位角
userId: "***", // 授权码
});

参考示例 地图初始化。

苏州 2000 矢量服务​

苏州 2000 矢量服务发布​

使用 Mapmost Studio,发布时选择“苏州 2000”。

苏州 2000 矢量服务加载​

案例​

map.addSource('nature', {
type: 'vector',
url: 'http://******/MapmostProxy/sip_nature_sz2000PC.json'
});
map.addLayer({
id: 'green_park_g',
type: 'fill',
source: 'nature',
'source-layer': 'green_park_g',
paint: {
'fill-color': 'rgba(209, 230, 180, 1)',
},
});

参考示例 加载矢量切片服务。

苏州 2000 栅格服务​

提供 map.addRasterLayer2 接口加载苏州 2000 坐标系的栅格服务。

  • 设置模型坐标系参数 project:'SZ2000'。

案例​

//加载WMTS栅格服务
let wmts_option = {
id: "wmts-test-layer",
project: "SZ2000",
source: {
tiles: ["http://******/CIC/SIPGIS/esri-tile/layerTileService/SZ2000_sipmap/rest/services/MapServer/tile/{z}/{y}/{x}"],
origin: [-5273200, 7202100],
resolutions: resolutions
}
};
map.addRasterLayer2(wmts_option);

参考示例 加载WMTS服务。

苏州 2000 GeoJSON 数据​

提供 mapmost.Convert.convertGeojson() 接口将苏州 2000 GeoJSON 数据转换成 SDK 坐标的 GeoJSON 数据。

案例​

fetch("http://../data/sz2000.geojson")
.then((res) => res.json())
.then((response) => {
map.addSource("someid", {
type: "geojson",
data: mapmost.Convert.convertGeojson(response),
});
map.addLayer({
id: "3d-buildings",
source: "someid",
type: "fill-extrusion",
paint: {
"fill-extrusion-color": "#aaa",
"fill-extrusion-height": 300,
"fill-extrusion-opacity": 0.8,
},
});
});

参考示例 加载 GeoJSON 数据。

苏州 2000 三维模型​

通过 map.addLayer(type:'model') 接口加载苏州 2000 三维模型。

  • 模型中心点坐标需要转换成 SDK 坐标。
  • 设置模型坐标系参数 project:'SZ2000'。

案例​

let center = mapmost.Convert.fromDefinedProj([339369.1795162731, 666472.346498875]);
let options = {
id: 'model_id',
type: 'model',
project:'SZ2000',
models: [{
type: 'glb',
url: './SM_DFZM_test.glb',//苏州2000三维模型
}],
center: center,
};
map.addLayer(options);

参考示例 加载三维模型。

苏州 2000 3DTiles 服务​

通过 map.addLayer(type:'3DTiles') 接口加载苏州 2000 3DTiles 数据。

案例​

map.addLayer({
id: "tile-3d-layer",
type: "3DTiles",
data: "http://******/sz2000/tileset.json",
});

参考示例 加载3DTiles。

苏州 2000 ArcGIS 动态服务​

通过 map.addArcGISDynamicLayer() 接口加载苏州2000 ArcGIS 动态服务。

  • 设置模型坐标系参数 project:'SZ2000'。

案例​

map.addArcGISDynamicLayer({
id: "arcgis-wms-test-layer",
project: "SZ2000", //坐标系
source: {
url: "http://******/cic/SIPGIS/esri-dyn/mxdService/SIPEPB_QYGH/rest/services/MapServer?",
layers: "show:0", // 显示的图层
format: "PNG", // 图片格式,默认为PNG
transparent: true, // 图片是否透明,默认为 true
},
});

参考示例 加载ArcGIS动态服务。

苏州 2000 量测计算​

扩展 mapmost.Utils 工具能力,支持苏州 2000 量测计算。

面积量测 area(data)​

计算一连串坐标构成闭合面数据的面积,输入数据为 SDK 坐标数组,输入坐标类型'SZ2000',返回值单位为平方米。

mapmost.Utils.area([[[3, 5],[3, 6],······,[3, 5]]],'SZ2000')

距离量测 distance(data)​

计算一连串坐标数据的长度,输入数据为 SDK 坐标数组,输入坐标类型'SZ2000',返回值单位为米。

mapmost.Utils.area([[[3, 5],[3, 6],······]],'SZ2000')

参考示例 二维量测。