Skip to content

地图GeoJson多边形数据转相似形状词云图片

Notifications You must be signed in to change notification settings

JohnHenryEden/MapToWordCloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MapToWordCloud


地图GeoJson多边形数据转相似形状词云图片

Turn GeoJson polygon data into wordcloud picture of similar shape.

1 安装 / Install

npm install maptowordcloud --save

2 使用 / Use

let geojson = geojson// 单个多边形的geojson数据
let wordcloudData = let wordcloudData = [
    ['la', 30],
    ['li', 28],
    ['lu', 26],
    ['le', 24],
    ['lo', 22],
    ['la', 20]
]
let opt = {
    list: wordcloudData,
    gridSize: 4,
    weightFactor: 1,
    fontFamily: 'serif',
    color: 'random-light',
    backgroundColor: 'rgba(0,0,0,0.0)',
    rotateRatio: 0.3,
    rotationSteps: 3,
    wait: 0
}
MapToWordCloud(geojson.features[0], opt, 10).then(src => {
    document.getElementById('wordcloud').src = src
})

3 目前待解决问题 / Current Issues

  1. 最后生成的图片无法与原图形非常贴合 / Image generated does not match with polygon perfectly
  2. 生成的图片大小不一,空白区域多 / Image generated have a lot of blank areas
  3. 无法很好应对奇形怪状的多边形,因为用的wordcloud2.js的shape / Does not compatible well with polygons with weird shapes

4 示例 / demo

在demo文件夹下,运行npm install, npm run dev, 打开页面localhost:8080可看效果 / Run npm install, npm run dev under demo folder, and access localhost:8080 in browser

About

地图GeoJson多边形数据转相似形状词云图片

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published