yy-profile

A plugin for maptalks to upload profile

Usage no npm install needed!

<script type="module">
  import yyProfile from 'https://cdn.skypack.dev/yy-profile';
</script>

README

maptalks profile上传插件

使用方式

1.项目中安装maptalks.profile插件

npm i maptalks.profile
import ProfileControl from 'maptalks.profile'

2.使用maptalks.profile插件

profile插件使用实例:

const map = new maptalks.Map(map', {
    center: [13.4, 52.5],
    zoom: 14,
    // profile配置
    profile: {
        name: 'test-profile', //项目名称(必填字段,若当前用户下存在同名项目,会被覆盖)
        description: '这是一个测试profile', //项目描述
        designer: 'xxxx', // 指定该项目设计者的用户名,指定后该用户可以打开并设计此项目,若不指定,默认为当前用户
    }
})
const control = new ProfileControl()
map.addControl(control);

3.指定需要上传到studio来进行配置的图层

示例代码:

 const vtLayer1 = new VectorTileLayer('vt1', {
      urlTemplate: URL + ACCESS_TOKEN,
      features: false,
      // 必填字段,指定filter和名称
      profileDatasets: [
        {
          uniqueName: '消防车',
          filter: ['num', '<', '1'],
        },
        {
          uniqueName: '警车',
          filter: ['num', '>', '1'],
        },
      ],
});
const vtLayer2 = new VectorTileLayer('vt2', {
      urlTemplate: URL + ACCESS_TOKEN,
      features: false,
      // 必填字段,指定filter和名称
      profileDatasets: [
        {
          uniqueName: '事件1',
          filter: ['num', '<', '1'],
        },
        {
          uniqueName: '事件2',
          filter: ['num', '>', '1'],
        },
      ],
});
// 如需添加多个图层,建议使用GroupGLLayer
new GroupGLLayer('group', [vtLayer1, vtLayer2]).addTo(map);

4.上传profile

代码写好后,刷新页面,在地图右上角点击上传profile按钮,即可上传profile。 ABC

5.下载profile

待设计师设计好样式并保存后,即可点击下载profile按钮查看目前设计好的样式。 ABC

LICENSE

MIT