Echarts map coordinates geoCoordMap data dynamic acquisition

This is a set of data in geoCoordMap format:

    var geoCoordMap = {
    '台湾': [121.5135,25.0308],
    '黑龙江': [127.9688, 45.368],
    '内蒙古': [110.3467, 41.4899],
    "吉林": [125.8154, 44.2584],
    '北京市': [116.4551, 40.2539],
    "辽宁": [123.1238, 42.1216],}

The method I thought at the beginning was to get three parameters, and the front end looped and spliced, but it ended in failure.

So switch to java background for data format conversion.

First encapsulate a type: similar to data

 Map<String, double[]> geocoordMap=new HashMap<String, double[]>();

Then the data obtained in a loop is encapsulated in the form of key and value.

  List<AnimalCheckandPass>  list = iAnimalCheckandPassService.selectAllData();
        Map<String, double[]> geocoordMap=new HashMap<String, double[]>();
        for(int i = 0; i < list.size(); i++){
            AnimalCheckandPass s = list.get(i);
            double[] value=new double[]{s.getSmx(),s.getSmy()};
            String key= s.getJczmc();
            geocoordMap.put(key, value);
        }

 

Guess you like

Origin blog.csdn.net/weixin_38959210/article/details/106614321