Amcharts-地图:自定义地图上的错误坐标(纬度/经度)(罗马尼亚县级)

Amcharts - Maps: bad coordinates (lat/long) on a custom map (county level Romania)

本文关键字:地图 纬度 罗马尼亚县 经度 坐标 自定义 错误 Amcharts-      更新时间:2023-09-26

我正在尝试在县地图上添加城市。在全尺寸地图(罗马尼亚级别)上,纬度和经度被共同绘制,但在县地图上,这些绘制错误。我想我应该重新缩放地图或城市的纬度/经度,我不知道。。。我应该如何根据城市纬度/经度生成县地图?

代码如下所示:http://jsfiddle.net/xzAx7/33/

    var map;
AmCharts.ready(function() {
    map = new AmCharts.AmMap();
    map.pathToImages = "http://www.ammap.com/lib/images/";
    //map.panEventsEnabled = true; // this line enables pinch-zooming and dragging on touch devices
    map.balloon.color = "#000000";
    var wordlDataProvider = {
        mapVar: AmCharts.maps.Cluj,
        getAreasFromMap: true,
        areas: [
            { id: "FR", color: "#4444ff" },
            { id: "RU", color: "#4444ff" },
            { id: "US", color: "#4444ff" }
        ],
        images: [{
                    title: "ClujNapoca",
                    latitude: 46.85307355,
                    longitude: 23.63327696,
                    type: "circle",
            color: "red",
            scale: 0.5
                }, {
                    title: "Turda",
                    latitude: 46.5745618,
                    longitude: 23.78573862,
                    type: "circle",
            color: "red",
            scale: 0.5
                }]
    };
    map.dataProvider = wordlDataProvider;
    map.areasSettings = {
        autoZoom: true,
        selectedColor: "#CC0000"
    };
    map.write("mapdiv");
});

我找到了解决方案。创建自定义地图时,需要定义"defs"属性(leftLongitude,…)。这在本条中规定——https://www.amcharts.com/tutorials/creating-custom-maps-for-javascript-ammap/
在amCharts中,文章解释了如何获得这些"defs"属性。

我更改了下面的代码以了解它是如何工作的

"defs": {
    "amcharts:ammap": {
        "projection":"mercator",
        "leftLongitude":"22.607117",
        "topLatitude":"47.363798",
        "rightLongitude":"24.261932",
        "bottomLatitude":"46.384241"
    }
}

演示:http://jsfiddle.net/xzAx7/35/