单击

时间:2017-10-23 09:09:54

标签: javascript jquery html css google-maps

我使用自定义标记自定义了Google地图。我需要将 Info Windows 集成到每个标记中。

来自:https://developers.google.com/maps/documentation/javascript/custom-markers

自定义标记代码

尝试整合来自https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple

信息窗口

这是我发现的一个相关问题(但这不是我想要的):https://stackoverflow.com/a/3059129/6191987

我的代码如下:

  html,
  body {
    height: 100%;
    margin: 0;
    padding: 0;
  }
  
  #map {
    height: 100%;
  }
<div id="map"></div>

<script>
  var map;

  function initMap() {
    map = new google.maps.Map(document.getElementById('map'), {
      zoom: 17,
      center: new google.maps.LatLng(40.712696, -74.005019),
      mapTypeId: 'roadmap'
    });

    var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
    var icons = {
      parking: {
        icon: iconBase + 'parking_lot_maps.png'
      },
      library: {
        icon: iconBase + 'library_maps.png'
      },
      info: {
        icon: iconBase + 'info-i_maps.png'
      }
    };

    var features = [{
      position: new google.maps.LatLng(40.712696, -74.005019),
      type: 'parking'
    }, {
      position: new google.maps.LatLng(40.712753, -74.006081),
      type: 'parking'
    }, {
      position: new google.maps.LatLng(40.713664, -74.007819),
      type: 'library'
    }];

    // Create markers.
    features.forEach(function(feature) {
      var marker = new google.maps.Marker({
        position: feature.position,
        icon: icons[feature.type].icon,
        map: map
      });
    });
  }

</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDvkk7wNQcIYXZ7S8XNG8cG-elq0QE2v3k&callback=initMap">


</script>

还添加了JSFiddle:https://jsfiddle.net/vishnuprasadps/7g33j2kz/

1 个答案:

答案 0 :(得分:2)

您想将什么内容作为infoWindow的内容?

但这似乎可以解决问题:

class A:
    def __init__(self, value=0):
        self.value = value

    def __add__(self, b):
        return A(self.value + b)

    def __str__(self):
        return str(self.value)

a = A()
print(a + 1 + 2)

https://jsfiddle.net/uqLxnyca/

祝你有个美好的一天。

相关问题