从数据库获取到谷歌地图信息窗口的链接
我开始非常热衷于谷歌地图,并设法将信息从我的 mysql 数据库获取到我网站上的地图。我现在面临的问题是我希望能够从信息窗口点击到我网站上的页面(链接也来自数据库)。
这是我现在使用的标准google api代码(“mijnlink”是链接),我尝试了很多不同的方法,但到目前为止还没有解决方案,希望你能帮助我找到答案:
GDownloadUrl("../phpsqlajax_genxml.php", function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var mijnlink = markers[i].getAttribute("mijnlink");
var naam = markers[i].getAttribute("naam");
var address = markers[i].getAttribute("address");
var hotelcampingbungalow = markers[i].getAttribute("hotelcampingbungalow");
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var marker = createMarker(point, mijnlink, naam, address, hotelcampingbungalow);
map.addOverlay(marker);
}
});
function createMarker(point, mijnlink, naam, address, hotelcampingbungalow) {
var marker = new GMarker(point, customIcons[hotelcampingbungalow]);
var html = "<b>" + mijnlink + hotelcampingbungalow + " " + naam + "</b> <br/>" + address;
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
i've started very enthousiastic with google maps and managed to get the info from my mysql dbase to the map on my site. The problem i'm facing now is that i want to be able to click through from the info window to a page on my site (the link also comes out of the dbase).
Here is the standard google api code I'm using now ('mijnlink' is the link), i've tried a lot of different things but so far no solution, hope you can help me to find the answer:
GDownloadUrl("../phpsqlajax_genxml.php", function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var mijnlink = markers[i].getAttribute("mijnlink");
var naam = markers[i].getAttribute("naam");
var address = markers[i].getAttribute("address");
var hotelcampingbungalow = markers[i].getAttribute("hotelcampingbungalow");
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var marker = createMarker(point, mijnlink, naam, address, hotelcampingbungalow);
map.addOverlay(marker);
}
});
function createMarker(point, mijnlink, naam, address, hotelcampingbungalow) {
var marker = new GMarker(point, customIcons[hotelcampingbungalow]);
var html = "<b>" + mijnlink + hotelcampingbungalow + " " + naam + "</b> <br/>" + address;
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
得到一些其他帮助,Createmarker函数中的var html必须是这样的:
Got some other help, the var html in the Createmarker function must be like this: