【问题标题】:How can I have the red label from Google Maps with Google Maps API? [duplicate]如何使用 Google Maps API 从 Google Maps 获得红色标签? [复制]
【发布时间】:2016-12-22 17:10:16
【问题描述】:

我正在使用 Google Maps API 在网站上创建带有坐标的地图。 我不知道如何在标记上添加相同的红色标签,以便在 Google 地图上进行搜索。

For example with the Eiffel Tower

我尝试使用title 选项,但是当我点击标记时它只显示一个标签。

【问题讨论】:

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


    【解决方案1】:

    来自google maps docs

    function initMap() {
      var myLatLng = {lat: -25.363, lng: 131.044};
    
      var map = new google.maps.Map(document.getElementById('map'), {
        zoom: 4,
        center: myLatLng
      });
    
      var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        title: 'Hello World!'
      });
      google.maps.event.addListener(marker, 'click', () => {
        infoWindow = new google.maps.InfoWindow({content: "This is DC!"})
        infoWindow.open(map, marker)
      })
    }
    

    【讨论】:

    • 我想你可以在之后设置信息窗口的样式。
    猜你喜欢
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多