//GeoJSON数据
let geoJsonData = {
type: "FeatureCollection",
features: [{
type: "Feature",
properties: {
styleId: 0
},
geometry: {
type: "Polygon",
coordinates: [[
[114.03274634, 22.53715749],
[114.03488384, 22.5281815],
[114.0396521, 22.5281815],
[114.04460265, 22.53191387],
[114.04828072, 22.53212417],
[114.04823425, 22.53619251],
[114.0468724, 22.537242],
[114.04373764, 22.53703171],
[114.04033123, 22.53757807],
[114.03728941, 22.53665436],
[114.03701776, 22.53602545],
[114.03583821, 22.53619251],
[114.03556298, 22.53732651],
[114.03274634, 22.53715749]
]]
}
},{
type: "Feature",
properties: {
styleId: 0
},
geometry: {
type: "LineString",
coordinates: [
[114.01176458,22.53816571],
[114.02493627,22.5380812],
[114.01785179,22.53057148],
[114.03188491,22.53053021]
]
}
},{
type: "Feature",
properties: {
styleId: 0
},
geometry: {
type: "Point",
coordinates: [114.02434649,22.52948067]
}
}]
};
let geoJson = new KMap.GeoJSON({
geoJson:geoJsonData,
pointStyle : [{
width: 32,
height: 32,
images: ['./images/c.png']
}],
polylineStyle : [{
strokeWidth: 4,
strokeColor: "blue",
strokeStyle: "solid",
strokeDasharray: [10, 50, 10]
}],
polygonStyle : [{
borderStyle: 'solid',
borderWidth:2,
borderColor:"#FF3030CC",
fillColor: "#FF8C69CC"
}]
});
map.add(geoJson);
//自定义多个显示样式
let style = [{
images: './images/mass0.png',
width:12,
height:12
}, {
images: './images/mass1.png',
width:10,
height:10
}, {
images: './images/mass2.png',
width:8,
height:8
}];
//海量数据,例子内容有限
let data = [{"point":[117.190182,39.125596],"name":"天津市","style":0},{"point":[116.405285,39.904989],"name":"北京市","style":1}];
let mass = new KMap.MassMarks(data,{
style : style
});
map.add(mass);
const bound = map.getBounds(); // 获取当前地范围
// 随机生成一些数据点
let data = [];
for (let i = 0; i < 2000; i++) {
data.push({
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [randomNum(bound.minX, bound.maxX), randomNum(bound.minY, bound.maxY)]
},
id: i+1,
properties: {
userData : {}
}
});
}
let cluster = new KMap.MarkerCluster(map,{
textFormat: 'abbr',
click : function(item) {
console.log('click',item);
}
});
cluster.setData(data);
cluster.show();
let heatmap = new KMap.HeatMap(map);
const bound = map.getBounds(); // 获取当前地范围
// 随机生成一些数据点及热度
let data = [];
for (let i = 0; i < 2000; i++) {
data.push({
position: [randomNum(bound.minX, bound.maxX), randomNum(bound.minY, bound.maxY)],
count: randomNum(1, 100)
});
}
heatmap.setDataSet({
data : data,
max : 100
});
heatmap.show();