如何将自定义地图和自定义数据添加到Highmaps? [英] How to add custom map and custom data to Highmaps?

查看:86
本文介绍了如何将自定义地图和自定义数据添加到Highmaps?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力将包含自定义数据的自定义地图添加到Highmaps中.我敢肯定这是一件很愚蠢的事情,但是我在网络上找不到任何示例和解释.

I am struggling with including a custom map with custom data into Highmaps. I am sure it's a pretty dumb thing, but I just can't find any examples and explanations on the web.

我有一个带数据的JSON文件和一个带地图的GeoJSON文件.因此,它可能看起来像这样:

I have a JSON file with the data, and a GeoJSON file with the map. So, it could look like this:

        $(function () 
        {
            $.getJSON('http://xxx/data/P_.json', function (data)
            {
                // Initiate the chart
                $('#container').highcharts('Map',
                {
                    series : [
                    {
                        data : data,
                        mapData: 'http://www/data/countries.geojson',
                        joinBy: ['Name', 'Countries'],
                    }]
                });
            });
        });         

但是很明显有些错误.我该如何添加自定义mapData?

But something is quite obviously wrong. How do I add then the custom mapData?

感谢您的帮助!

推荐答案

其中有一条有关如何创建自定义geoJSON的说明:

There is a instruction about how to create custom geoJSON: http://www.highcharts.com/docs/maps/custom-geojson-maps

在9.中,有一个指向jsFiddle的链接,该链接显示了应如何解析geoJSON文件以供Highcharts用作mapData: http://jsfiddle.net/highcharts/xbzxfx2L/

In 9. there is link to jsFiddle that show how geoJSON file should be parsed to be used by Highcharts as mapData: http://jsfiddle.net/highcharts/xbzxfx2L/

$('#run').click(function () {     
    var geojson = $.parseJSON($('#geojson').val());

    // Initiate the chart
    $('#container').slideDown().highcharts('Map', {
        series: [{
            mapData: geojson
        }]
    });    
});

这篇关于如何将自定义地图和自定义数据添加到Highmaps?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆