【发布时间】:2015-09-01 00:10:08
【问题描述】:
我在谷歌地图上添加了一些搜索结果的标记。
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
var contentString="";var image_path1="";
contentString += '<div class="browse-map-venue" style="padding:5px;width: 230px;">';
contentString += '<div class="rating" style="float: right; padding-right: 10px;">';
contentString += '<script type="text/javascript" src="<?php echo base_url(); ?>media/front/js/jquery.raty.min.js"><\/script>';
contentString += '<script>';
contentString += '$(function() {';
contentString += '$("#rating_fixed_rate_pop_'+ i +'").raty({';
contentString += 'readOnly: true,';
contentString += 'half: true,';
contentString += 'start: '+ locations[i][6] +',';
contentString += 'score: '+ locations[i][6] +',';
contentString += 'path: "<?php echo base_url(); ?>media/front/img"';
contentString += '});';
contentString += '});';
contentString += '<\/script> ';
contentString += '<div id="rating_fixed_rate_pop_'+ i +'"></div>';
contentString += '<a href="javascript:void(0);">'+ locations[i][7] +' reviews</a>';
contentString += '</div>';
contentString += '</div>';
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1],locations[i][2]),
title: locations[i][3],
info: contentString,
map: map
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(this.info);
infowindow.open(map, this);
});
}
但是我需要添加星级评分,当我点击标记时不会应用到它。
注意:当我们从控制台编辑为评分编写的脚本时,在按下回车键后它会显示星星。但我只需要在信息窗口中单击标记时显示这些内容。
提前致谢!
【问题讨论】:
-
1.浏览器看到的代码是什么样的? 2. 在
domready事件触发之前,信息窗口不会成为DOM 的一部分。 -
以上所有代码都是在ajax调用后用脚本编写的。我刚刚编写了使用 infowindow 显示标记所需的代码
-
php 是一种服务器端语言,如果出现在浏览器中,它将不起作用。
-
在上面的代码中,我猜 php 仅用于路径。我正在研究 php,上面的代码在搜索结果页面中,我需要在谷歌地图上显示数据并获取搜索结果。根据我的假设 php 不会影响此功能
标签: javascript google-maps google-maps-api-3 infowindow raty