Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在自定义集群标记-谷歌地图中打开信息窗口_Javascript_Google Maps_Google Maps Api 3_Google Maps Markers - Fatal编程技术网

Javascript 如何在自定义集群标记-谷歌地图中打开信息窗口

Javascript 如何在自定义集群标记-谷歌地图中打开信息窗口,javascript,google-maps,google-maps-api-3,google-maps-markers,Javascript,Google Maps,Google Maps Api 3,Google Maps Markers,函数初始化映射{ var map=new google.maps.Mapdocument.getElementByIdmap{ 缩放:12, 中心:{ 拉脱维亚:37.773972, 液化天然气:-122.431297 }, 手势处理:贪婪, disableDefaultUI:true }; var标签=ABCDefghijklmnopqrstuvxyz; var infoWin=new google.maps.InfoWindow; var markers=locations.mapfunct

函数初始化映射{ var map=new google.maps.Mapdocument.getElementByIdmap{ 缩放:12, 中心:{ 拉脱维亚:37.773972, 液化天然气:-122.431297 }, 手势处理:贪婪, disableDefaultUI:true }; var标签=ABCDefghijklmnopqrstuvxyz; var infoWin=new google.maps.InfoWindow; var markers=locations.mapfunctionlocation,i{ var htmlMarker=新的HTMLMarkerlocation.lat,location.lng; google.maps.event.addListenerhtmlMarker,“单击”,函数EVT{ infoWin.setcontent打开我的信息窗口; infoWin.openmap,htmlMarker; }; 返回htmlMarker; }; var markerCluster=新的MarkerClusterermap,markers{ 图像路径:https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m }; } google.maps.event.addDomainListenerWindow,“加载”,initMap; 变量位置=[{ 拉脱维亚:37.77, 液化天然气:-122.44 }, { 拉脱维亚:37.78, 液化天然气:-122.45 }, { 拉脱维亚:37.79, 液化天然气:-122.42 }, { 拉脱维亚:37.72, 液化天然气:-122.43 }, { 拉脱维亚:37.74, 液化天然气:-122.42 }, { 拉脱维亚:37.75, 液化天然气:-122.41 }, { 拉脱维亚:37.75, 液化天然气:-122.43 }, { 拉脱维亚:37.79, 液化天然气:-122.43 }, { 拉脱维亚:37.78, 液化天然气:-122.43 } ]; 功能HTMLMarkerlat,液化天然气{ this.lat=lat; 这是液化天然气=液化天然气; this.pos=new google.maps.LatLnglat,lng; } HTMLMarker.prototype=新的google.maps.OverlayView; HTMLMarker.prototype.onRemove=函数{ 如果this.div&&this.div.parentNode&&this.div.parentNode.removeChild this.div.parentNode.removeChildthis.div; } HTMLMarker.prototype.getDragable=函数{}; HTMLMarker.prototype.getPosition=函数{ 把这个还给我 }; HTMLMarker.prototype.onAdd=函数{ this.div=document.createElement'div'; this.div.className=htmlMarker; this.div.style.position='absolute'; this.div.innerHTML=$500; var panes=this.getPanes; panes.overlayImage.appendChildthis.div; } HTMLMarker.prototype.draw=函数{ var OverlyProjection=this.getProjection; var位置=过度投影.fromLatLngToDivPixelthis.pos; var panes=this.getPanes; this.div.style.left=position.x+'px'; this.div.style.top=position.y+'px'; } html, 身体 地图{ 身高:100%; 宽度:100%; 填充:0px; 边际:0px; } .htmlMarker{ 背景色:黑色; 边界半径:50%; 填充:10px; 颜色:白色; } 编写的HTMLMarker不处理单击事件。要添加单击事件处理,请更改.onAdd方法以添加一个单击事件侦听器,该侦听器触发对象上的单击事件并将其位置作为事件的属性返回

HTMLMarker.prototype.onAdd = function() {
  this.div = document.createElement('DIV');
  this.div.className = "htmlMarker";
  this.div.style.position = 'absolute';
  this.div.style.cursor = 'pointer';
  this.div.innerHTML = "$500";
  var that = this;
  this.div.addEventListener("click", function(evt) {
    google.maps.event.trigger(that, 'click', {latLng: that.pos})
  })
  var panes = this.getPanes();
  panes.overlayImage.appendChild(this.div);
}
html, 身体 地图{ 身高:100%; 宽度:100%; 保证金:0; 填充:0; } .htmlMarker{ 背景色:黑色; 边界半径:50%; 填充:10px; 颜色:白色; } 函数初始化映射{ var map=new google.maps.Mapdocument.getElementByIdmap{ 缩放:12, 中心:{ 拉脱维亚:37.773972, 液化天然气:-122.431297 }, 手势处理:贪婪, disableDefaultUI:true }; var标签=ABCDefghijklmnopqrstuvxyz; var infoWin=new google.maps.InfoWindow; var markers=locations.mapfunctionlocation,i{ var htmlMarker=新的HTMLMarkerlocation.lat,location.lng; google.maps.event.addListenerhtmlMarker,“单击”,函数EVT{ console.loghtmlMarker单击@+evt.latLng.toUrlValue6; infoWin.setcontent打开我的信息窗口marker+i; infoWin.setOptions{ pixelOffset:new google.maps.Size20,0 } infoWin.openmap,htmlMarker; }; 返回htmlMarker; }; var markerCluster=新的MarkerClusterermap,markers{ 图像路径:https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m }; } google.maps.event.addDomainListenerWindow,“加载”,initMap; 变量位置=[{ 拉脱维亚:37.77, 液化天然气:-122.44 }, { 拉脱维亚:37.78, 液化天然气:-122.45 }, { 拉脱维亚:37.79, 液化天然气:-122.42 }, { 拉脱维亚:37.72, 液化天然气:-122.43 }, { 拉脱维亚:37.74, 液化天然气:-122.42 }, { 拉脱维亚:37.75, 液化天然气:-122.41 }, { 拉脱维亚:37.75, 液化天然气:-122.43 }, { 拉脱维亚:37.79, 液化天然气:-122.43 }, { 拉脱维亚:37.78, 液化天然气:-122.43 } ]; 功能HTMLMarkerlat,液化天然气{ this.lat=lat; 这是液化天然气=液化天然气; this.pos=new google.maps.LatLnglat,lng; } HTMLMarker.prototype=新的google.maps.OverlayView; HTMLMarker.prototype.onRemove=函数{ 如果this.div&&this.div.parentNode&&this.div.parentNode.removeChild this.div.parentNode.removeChildthis.div; } HTMLMarker.prototype.getDragable=函数{}; HTMLMarker.prototype.getPosition=函数{ 把这个还给我 }; HTMLMarker.prototype.onAdd=函数{ this.div=document.createElement'div'; this.div.className=htmlMarker; 这个.div.style.position =绝对值; this.div.style.cursor='pointer'; this.div.innerHTML=$500; var=这个; this.div.addEventListenerclick,functionevt{ console.logclick; google.maps.event.trigger“点击”{ 拉廷:那个 } } var panes=this.getPanes; panes.overlayImage.appendChildthis.div; } HTMLMarker.prototype.draw=函数{ var OverlyProjection=this.getProjection; var位置=过度投影.fromLatLngToDivPixelthis.pos; var panes=this.getPanes; this.div.style.left=position.x+'px'; this.div.style.top=position.y+'px'; } google.maps.event.addDomainListenerWindow,“加载”,initMap;
非常感谢。你是唯一。英雄联盟