Google Maps JavaScript API V3如何仅限Placemark显示名称 [英] Google Maps Javascript API V3 how to Placemark show name only

查看:168
本文介绍了Google Maps JavaScript API V3如何仅限Placemark显示名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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

 <文件夹> 
<名称>点要素< /名称>
< description>点要素< / description>
<地标>
< description><![CDATA [LABEL< B> B> ELEVATION< / B> = -2147483648.0000000]]>< / description>
< name> lnd_a< / name>
< Point>
<坐标> 126.3680042851,34.7669071990,-2147483648.000< /坐标>
< / Point>
< /地标>
<! - 我的KML文件有更多行 - >
< / Folder>

============= Script Source ====== =========

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

< script type =text / javascript>
函数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);
}



< img src =https://i.stack.imgur.com/RrVMk.pngalt =Chrome网络中的Google地图>
用Google蓝色地图显示的Google地图地标。




在Google地球地标中显示的名称。
$ b

这些截图基于相同的KML文件。



如何在浏览器中显示Google地图的名称? ?

解决方案

我从来没有使用过它,但有一个库可以在标记上显示标签。如果您将透明标记与标签一起使用,您可能会得到期望的结果。

MarkerWithLabel



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



在Google Maps API v3中使用自定义标签创建标记



这将是一个我猜是使用KML图层的替代方案。


As a Title, I want show Placemark with Name field. Basically, google map show Placemark with blue balloons. but i don't wanna see this blue ballons. Just show Name only like google earth. is it possible with 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 Source===============

<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);
  }

In Chrome Google Map Placemark shown with blue ballons.

In Google Earth Placemark shown with just name.

These screenshot base on same KML file.

How to show only name with Google Maps in Browser??

解决方案

I've never used it, but there is a library to show labels on a marker. If you used a transparent marker with a label you may get the desired outcome.

MarkerWithLabel

If that doesn't work, I used to create custom labels for markers using an OverlayView.

Create marker with custom labels in Google Maps API v3

This would be an alternative to using KML Layers I guess.

这篇关于Google Maps JavaScript API V3如何仅限Placemark显示名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆