How can i show text under marker

前端 未结 2 627
南旧
南旧 2020-12-18 07:44

I have one problem when showing markers on a map. I would like to show some text below the marker, but I can not do it anyway. This is my example code, I wonder what I need

2条回答
  •  伪装坚强ぢ
    2020-12-18 08:46

    function initMap() {
        var myLatLng = {lat: 47.363362, lng: 8.485823};
    
        var map = new google.maps.Map(document.getElementById('map'), {
          zoom: 7,
          center: myLatLng,
          mapTypeId: google.maps.MapTypeId.SATELLITE
        });
    
        var marker = new google.maps.Marker({
          position: myLatLng,
          map: map,
          title: 'Hello World!',
          icon: {
            labelOrigin: new google.maps.Point(16,64),
            url: "https://drive.google.com/uc?id=0B3RD6FDNxXbdVXRhZHFnV2xaS1E"
          },
          label: {
            text: "Hello world!",
            color: "white",
            fontWeight: "bold",
            fontSize: "16px"
          }
        });
    }
    /* Always set the map height explicitly to define the size of the div
           * element that contains the map. */
    #map {
      height: 100%;
    }
    /* Optional: Makes the sample page fill the window. */
    html, body {
      height: 100%;
      margin: 0;
      padding: 0;
    }

提交回复
热议问题