使用Google地图的geoJson文件中的点的自定义标记

 sucbenson-lee_905 发布于 2023-01-07 15:08

我正在使用GeoJSON作为Google地图的数据源.我正在使用API​​的v3来创建数据层,如下所示:




我的GeoJSON数据的来源如下:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "icon": "/static/images/icons/map-marker-do.png",
        "coordinates": [
          -0.53743,
          53.23437
        ]
      },
      "properties": {
        "name": "Cathedral",
        "description": "One of Europe’s finest Gothic buildings, once the tallest building in the world that dominates Lincoln's skyline.",
        "icon": "/static/images/icons/map-marker-do.png"
      }
    }
  ]
}

我正在试图做的是使地图来自于JSON的"图标"属性上标记的图标,但无法弄清楚如何获取数据更改默认标记.有人可以提供任何建议吗?谢谢.

1 个回答
  • 使用样式功能(样式功能使您可以根据特定功能应用样式)

      map.data.setStyle(function(feature) {
        return {icon:feature.getProperty('icon')};
      });
    

    2023-01-07 15:09 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有