【发布时间】:2020-06-15 02:27:25
【问题描述】:
这是我的输出,只是一个矩形,当我在geojson.io 或mapshapper 尝试它时不像地图,而且我的浏览器控制台中没有错误..
我的 Geojson
我已经在 features 对象中使用了“id”,这是我的示例 geoJson:
{type: "FeatureCollection", features: Array(14)}
features: Array(14)
0:
geometry: {type: "Polygon", coordinates: Array(1)}
properties:{
id: 332112
kabupaten: "DEMAK"
kecamatan: "Bonang"
provinsi: "JAWA TENGAH"
__proto__: Object
type: "Feature"
__proto__: Object
}
1: {type: "Feature", geometry: {…}, properties: {…}}
2: {type: "Feature", geometry: {…}, properties: {…}}
AmChart 代码
我的 vue js 代码加载 amcharts 地图
import * as am4core from "@amcharts/amcharts4/core"
import * as am4maps from "@amcharts/amcharts4/maps"
import robots from "./assets/demak"
export default {
mounted() {
let map = am4core.create("chartdiv", am4maps.MapChart)
map.geodata = robots
console.log(robots);
map.projection = new am4maps.projections.Miller()
var polygonSeries = map.series.push(new am4maps.MapPolygonSeries())
polygonSeries.useGeodata = true
var polygonTemplate = polygonSeries.mapPolygons.template;
polygonTemplate.fill = am4core.color("#74B266");
polygonTemplate.tooltipText = "{KABUPATEN}";
var hs = polygonTemplate.states.create("hover");
hs.properties.fill = am4core.color("#367B25");
// Add zoom control
map.zoomControl = new am4maps.ZoomControl();
},
beforeDestroy() {
if (this.map) {
this.map.dispose()
}
}
}
【问题讨论】:
-
您的浏览器控制台中报告了任何错误吗?
-
我的浏览器控制台没有错误..
标签: javascript vue.js dictionary geojson amcharts