reinhard.lee
reinhard.lee

Reputation: 503

Google Maps Javascript API V3 how to Placemark show name only

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

Google Maps in Chrome Web In Chrome Google Map Placemark shown with blue ballons.

Google Earth Placemark 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??

Upvotes: 1

Views: 4805

Answers (2)

Seain Malkin
Seain Malkin

Reputation: 2303

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.

Upvotes: 2

Dr.Molle
Dr.Molle

Reputation: 117314

There is no implemented method to show anything else than an image there.

So 1 option could be: use the iconStyle to put there the name(an image that contains the name, this may be created by a serverside script that accepts parameters, so they don't need to be static).

Another option(using the Maps-JS-API): Instead of showing the KML-layer, parse the layer on your own and create custom overlays with the names.

Upvotes: 1

Related Questions