示例#1
0
        }]
    },
}

max_p = max([item['population'] for item in data])

for item in data:
    item.update({'z': item['population']})
    item.update({
        'color':
        interpolateRGB([0, 10, 255], [255, 10, 0], item['population'] / max_p)
    })

H.add_map_data(geojson,
               name='Basemap',
               borderColor='#606060',
               nullColor='rgba(200, 200, 200, 0.2)',
               showInLegend=False)
H.add_data_set(geojson_handler(geojson, 'mapline'),
               'mapline',
               'Separators',
               showInLegend=False,
               enableMouseTracking=False)
H.add_data_set(data,
               'mapbubble',
               'Cities',
               dataLabels={
                   'enabled': True,
                   'format': '{point.capital}'
               },
               maxSize='12%',
    "mappoint" will return GeoJSON points and multipoints.
    default: "map"
"""

mapdata = geojson_handler(geojson)
lines = geojson_handler(geojson, 'mapline')
"""
Change the name property in map data. 
This is doing the same thing as the second JS function added in the example us-counties.py 
"""
for x in mapdata:
    x.update({
        'name':
        x['name'] + ', ' + x['properties']['hc-key'].split('-')[1].upper()
    })

H.add_data_set(data,
               'map',
               'Unemployment rate',
               joinBy=['hc-key', 'code'],
               tooltip={'valueSuffix': '%'},
               borderWidth=0.5,
               states={'hover': {
                   'color': '#bada55'
               }})
H.add_data_set([lines[0]], 'mapline', 'State borders', color='white')
H.add_data_set([lines[3]], 'mapline', 'Separator', color='gray')
H.add_map_data(mapdata)

H.htmlcontent
                    'align': 'left',
                    'x': 5,
                    'verticalAlign': 'middle'
                }
            }]

fake_data = []
options = {
        'title': {
            'text': 'Highmaps basic lat/lon demo'
        },

        'mapNavigation': {
            'enabled': True
        },

        'tooltip': {
            'headerFormat': '',
            'pointFormat': '<b>{point.name}</b><br>Lat: {point.lat}, Lon: {point.lon}'
        },
        
    }
H.add_map_data(geojson, name = 'Basemap' ,borderColor = '#A0A0A0',
            nullColor = 'rgba(200, 200, 200, 0.3)',
            showInLegend = False)    
H.add_data_set(data,'mappoint','Cities',color = 'Highcharts.getOptions().colors[1]', is_coordinate = True)
H.add_data_set(geojson_handler(geojson, 'mapline'),
    'mapline','Separators',color = '#707070', showInLegend = False, enableMouseTracking = False)
H.set_dict_options(options)

H.htmlcontent
"""

mapdata = geojson_handler(geojson)
lines = geojson_handler(geojson, 'mapline')

"""
Change the name property in map data. 
This is doing the same thing as the second JS function added in the example us-counties.py 
"""
for x in mapdata:
    x.update({'name':x['name']+', '+x['properties']['hc-key'].split('-')[1].upper()})


H.add_data_set(data, 'map', 'Unemployment rate', joinBy = ['hc-key', 'code'], 
     tooltip = {
                    'valueSuffix': '%'
                },
                borderWidth = 0.5,
                states = {
                    'hover': {
                        'color': '#bada55'
                    }
                }
                )
H.add_data_set([lines[0]], 'mapline', 'State borders', color = 'white')
H.add_data_set([lines[3]], 'mapline', 'Separator', color = 'gray')
H.add_map_data(mapdata)

H.htmlcontent