import arcmm from "arcmm";
一.加载arcgis JsApi模块:
arcmm.Arc.init(()=>{
//加载完成后
})
二.全局事件使用:
arcmm.Evo.fire("eventName",data);
arcmm.Evo.add("eventName",evt=>{
//doSomething 数据为 evt.data
},this);
arcmm.Evo.removeAll(this); 移除对象的所有事件
三.配置表:
//创建对象
import arcmm from "./index.js";
import "./arcgis/style/arcgis_main.css";
import "./arcgis/style/arcgis_map.css";
//创建对象
let mm = new arcmm.MapManager();
//初始化配置
mm.init({
containerId: "map",//地图容器ID
basemap: [
{
name: "行政图",
type: "tdt",
tk: "44964a97c8c44e4d04efdf3cba594467",
layers: ["vec_w", "cva_w"]
},
{
name: "卫星图",
type: "tdt",
tk: "44964a97c8c44e4d04efdf3cba594467",
layers: ["img_w", "ibo_w", "cia_w"]
},
{
name: "深蓝图",
type: "arc",
layers: [
{
url:
"https://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer",
id: "blue"
}
]
}
],
division: { type: "tile", number: 1, column: 1, action: "normal" }, //action: normal/rolling
widgets: ["分屏", "卷帘", "底图", "图层"],
layers: [
{
id: "layerId",
name: "林地分布",
type: "FeatureLayer",
url:
"http://47.111.8.170:6080/arcgis/rest/services/ShenJi/ForestryResources/MapServer/0",
sql: "",
render: "ErDiao",
show: true,
icon: "",
template: {
type: "normal",
title: "测试",
contentInfo: { "所属单位": "{ssdw}", "编号": "12313" }
}
}
],
screens: [{
basemapIndex: 2,
visibleLayers: ["all"]
},
{ basemapIndex: 2 },
{ basemapIndex: 2 }],
location: {
type: "layer",
id: "all"
}
});
###方法 增加图层
mm.addLayer({
id: "layerId",
name: "林地分布",
type: "FeatureLayer",
url:
"http://47.111.8.170:6080/arcgis/rest/services/ShenJi/ForestryResources/MapServer/0",
sql: "",
render: "ErDiao",
show: true,
icon: "",
template: {
type: "normal",
title: "测试",
contentInfo: { "所属单位": "{ssdw}", "编号": "12313" }
}
})
移除图层
mm.removeLayer("layerId")
移除图层
mm.removeAllLayers()
###图表层相关
mm.setChartLayer(init, update, destory)
//init(domId)
/** 地理坐标转屏幕坐标 ESRI引用:"esri/geometry/Point", "esri/geometry/ScreenPoint" 作用:地理坐标转屏幕坐标 参数:[{id:"pie1",lon:105,lat:43}]//此数组需要存储,在改变的时候一直使用 返回:[{id:"pie1",x:300,y:200}](看一下比例尺要不要放回,根据比例尺确定饼状图大小) 方法示例:let cosArray=getScreenCos([{id:"pie1",lon:105,lat:43}]); */
mm.getScreenCos(data)