javascript - Google Maps Javascript API V3 如何地标仅显示名称

标签 javascript google-maps google-maps-api-3 kml

作为标题,我想显示带有名称字段的地标。 基本上,谷歌地图显示带有蓝色气球的地标。 但我不想看到这个蓝色气球。就像谷歌地球一样只显示名称。 是否可以使用 google maps javascript api?

=============KML===============

<Folder>
   <name>Point Features</name>
   <description>Point Features</description>
   <Placemark>
     <description><![CDATA[LABEL<BR><BR><B>ELEVATION</B> = -2147483648.0000000]]></description>
     <name>lnd_a</name>
     <Point>
       <coordinates>126.3680042851,34.7669071990,-2147483648.000</coordinates>
     </Point>
   </Placemark>
   <!-- MY KML FILE HAS MORE LINE -->
</Folder>

=============脚本源===============

<script type="text/javascript"src="https://maps.google.com/maps/api/js?sensor=false"></script>

<script type="text/javascript">
  function initialize() {
    var latlng = new google.maps.LatLng(34.7958078334,126.4441270970);
    var myOptions = {
        zoom: 14,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.SATELLITE
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    var ctaLayer = new google.maps.KmlLayer('http://MYSITES/kml/101.kml');
    ctaLayer.setMap(map);
  }

Google Maps in Chrome Web 在 Chrome 中,Google map 地标以蓝色气球显示。

Google Earth Placemark 在 Google 地球中,地标仅显示名称。

这些屏幕截图基于同一个 KML 文件。

如何在浏览器中使用谷歌地图只显示姓名??

最佳答案

我从未使用过它,但有一个库可以在标记上显示标签。如果您使用带有标签的透明标记,您可能会得到想要的结果。

MarkerWithLabel

如果这不起作用,我曾经使用 OverlayView 为标记创建自定义标签。

Create marker with custom labels in Google Maps API v3

我猜这是使用 KML 图层的替代方法。

关于javascript - Google Maps Javascript API V3 如何地标仅显示名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14330211/

相关文章:

javascript - 将 PHP 变量作为字符串传递给 javascript

javascript - javascript 函数中变量的测试值 - sinon/chai

php - PHP 中的 MongoDB 查询

google-maps - 我需要捕获多边形下方 map 上的点击事件

android - 谷歌在 map 上的行车方向与航路点

javascript - Google Maps API - 如何为当前标记设置中心和缩放?

javascript - 在 Chart.js 中对一个数据集中的各个点进行样式设置

javascript - 选择没有某些后代的元素内容

javascript - 添加一个点以扩展多边形而不将其附加到 Google map 中?

javascript - 无法在 google api 上获取标记