[英]Why can't I click my markers to pull up infowindow in Google Maps anymore?
I have a web application using the Google Maps API and has been working fine. 我有一个使用Google Maps API的网络应用程序,并且运行良好。 The page still works but one day randomly I found out that the markers can no longer be clicked but has worked for me previously for a long time.
该页面仍然有效,但是有一天我随机发现标记不能再被单击,但是以前已经为我工作了很长时间。 I have not made any change to the code prior to this happening.
在此之前,我没有对代码进行任何更改。
Below is my code for the infowindow section: 下面是我的信息窗口部分的代码:
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
for (i = 0; i < markers.length; i++) {
var data = markers[i]
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: "Permit#" + " " + data.permit,
icon: 'GoogleMapsMarkers/' + data.icon + '.png'
});
(function (marker, data) {
google.map.event.addListener(marker, "click", function (e) {
infoWindow.setContent('<b>' + data.loc + " " + data.type + '</b>' + '<br/><a target=_blank href="ViewPermit.aspx?PermNum=' + data.permit + '">' + 'Open Permit #' + " " + data.permit + '</a>');
infoWindow.open(map, marker);
});
})(marker, data);
}
I am using the script below for the api: 我将以下脚本用于api:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3&key=My_Key"></script>
I tried this and still same issue: 我尝试了这个并且还是同样的问题:
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=My_Key&callback=initMap">
Has something changed that I am not aware of? 我不知道有什么变化吗?
First of all, you should not share any API keys, passwords, any sensible data information. 首先,您不应共享任何API密钥,密码和任何明智的数据信息。 Try to use placeholders eg (API key), [API Key].
尝试使用占位符,例如(API密钥),[API密钥]。
Have you tried to follow Google's official documentation: https://developers.google.com/maps/documentation/javascript/infowindows 您是否尝试过遵循Google的官方文档: https : //developers.google.com/maps/documentation/javascript/infowindows
Hope this will help you in your quest. 希望这对您的追求有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.