简体   繁体   English

如何从google.maps.InfoWindow传递变量?

[英]How to pass variable from the google.maps.InfoWindow?

I'm trying to transfer variable from the google.maps.InfoWindow: 我正在尝试从google.maps.InfoWindow传输变量:

var infoWindow = new google.maps.InfoWindow({
    content: '<a href="#pinDetails?0?'+pin[i][2]+'">'+pin[i][2]+'</a>',
});

from the client site there is a full link at the html: 从客户端站点,在html上有完整链接:

<a href="#pinDetails?0?SWA-ER-002">SWA-ER-002</a>

but I can receive only the part before the question mark of the link. 但我只能收到链接问号之前的部分。

If I check the linkwindow.location.href I see only: 如果我检查linkwindow.location.href我只会看到:

index.html#pinDetails but not index.html#pinDetails?0?SWA-ER-002 index.html#pinDetails但不是index.html#pinDetails?0?SWA-ER-002

How can I transfer the data from the google.maps.InfoWindow ? 如何从google.maps.InfoWindow传输数据?

Thanks 谢谢

? is a reserved url character. 是保留的网址字符。 Try replacing ? 尝试更换? with | | so example 这样的例子

var infoWindow = new google.maps.InfoWindow({
    content: '<a href="#pinDetails|0|'+pin[i][2]+'">'+pin[i][2]+'</a>',
});

which would show up as 会显示为

<a href="#pinDetails|0|SWA-ER-002">SWA-ER-002</a>

Thank you @Rohit Agre, the problem has been solved. 谢谢@Rohit Agre,问题已解决。 I've changed the event handler from $(document).on("pageshow", "#pinDetails", function() to $(document).on("click", "#details", function() 我已将事件处理程序从$(document).on("pageshow", "#pinDetails", function()更改$(document).on("click", "#details", function()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM