首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MapQuest在标志图标中添加文本

MapQuest在标志图标中添加文本
EN

Stack Overflow用户
提问于 2022-06-28 17:01:44
回答 1查看 42关注 0票数 0

我有以下代码,我想在每个图标中添加不同的文本。例如,“魁北克”的位置应该输入"08h00“表示"Beaupre”。“15小时”等

代码语言:javascript
复制
<html>
  <head>
    <script src="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest.js"></script>
    <link type="text/css" rel="stylesheet" href="https://api.mqcdn.com/sdk/mapquest-js/v1.3.2/mapquest.css"/>

    <script type="text/javascript">
      window.onload = function() {
        L.mapquest.key = '';

        // Geocode three locations, then call the createMap callback
        L.mapquest.geocoding().geocode(['Quebec,Qc', 'Beaupre,Qc', 'Montmagny,Qc'], createMap);

        function createMap(error, response) {
          // Initialize the Map
          var map = L.mapquest.map('map', {
            layers: L.mapquest.tileLayer('map'),
            center: [0, 0],
            zoom: 12
          });

          // Generate the feature group containing markers from the geocoded locations
          var featureGroup = generateMarkersFeatureGroup(response);

          // Add markers to the map and zoom to the features
          featureGroup.addTo(map);
          map.fitBounds(featureGroup.getBounds());
        }

        function generateMarkersFeatureGroup(response) {
          var group = [];
          for (var i = 0; i < response.results.length; i++) {
            var location = response.results[i].locations[0];
            var locationLatLng = location.latLng;

            // Create a marker for each location
            var marker = L.marker(locationLatLng, {icon: L.mapquest.icons.flag()})
                           
              .bindPopup(location.adminArea5 + ', ' + location.adminArea3);

            group.push(marker);
          }
          return L.featureGroup(group);
        }
      }
    </script>
  </head>

  <body style="border: 0; margin: 0;">
    <div id="map" style="width: 100%; height: 530px;"></div>
  </body>
</html>

有人能帮帮我吗?

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-28 18:42:57

尝试为类似图标的标志设置符号:L.mapquest.icons.flag({符号:“08h00”})

这里有更多详细信息:https://developer.mapquest.com/documentation/mapquest-js/v1.3/l-mapquest-icons/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72790543

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档