先看效果图:
RS制作页面布局
实现步骤:
1.在RS中插入一个一行两列的表格,拖入一个HTML项到左边的单元格中,拷贝如下代码到该HTML项中:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<div id="map" style="width: 700px; height: 400px"></div>
<script type="text/javascript">
var latlng = new google.maps.LatLng(40.756, -73.986);
var options = {
center : latlng,
zoom : 1,
mapTypeId : google.maps.MapTypeId.ROADMAP
};
// Creating the map
var map = new google.maps.Map(document.getElementById('map'), options);
var geocoder = new google.maps.Geocoder();
var infowindow;
function displayLocation(a) {
displayMap(a, 0);
}
function displayInfo(a) {
displayMap(a, 1);
}
function displayMap(address, displayInfo) {
geocoder.geocode( {'address' : address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker( {
map : map,
position : results[0].geometry.location
});
if (!infowindow) {
infowindow = new google.maps.InfoWindow();
}
infowindow.setContent(address);
if (displayInfo == 1) {
infowindow.open(map, marker);
}
} else {
// alert("Incorect adress: " +status+address);
}
});
}
</script>
2.拖入一个列表到右边的单元格中,然后从Go Sales(query)--->Sales(query)--->Branch中拖入Country、City、Address 1三个数据项到列表中。
3.拖入一个数据项到查询项中,名为Address 2,表达式如下:
replace([Sales (query)].[Branch].[Address 1],'''','''')
4.拖入一个HTML项到列表中的Address 1后面,修改其列表表头为Map,修改其Source Type为报表表达式,然后拷贝下面的代码到该HTML项中:
'<a href="#" onClick="displayInfo( '''+ [Query1].[Address 2] +', '+[Query1].[City] +', '+[Query1].[Country]+''')"> Show Map</a>
<script>
displayLocation("' + [Query1].[Address 2] + ', '+[Query1].[City] +', '+[Query1].[Country]+ '");
</script>'
5.选中整个列表,在Properties属性中,将Address 2选中。
6.运行报表,查看结果。
备注:如果代码报这样的错误“geocoder为null或者undefined”,只需要将<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>中的sensor=true改为sensor=false,如果sensor=false报错,改为sensor=true就行啦,自己多试几次就出来了。
添加新评论19 条评论
2015-05-15 10:15
2015-05-15 09:19
2014-09-18 10:42
2013-12-16 21:45
2013-09-02 16:14
2013-04-02 00:26
2012-11-05 17:29
2012-11-05 17:12
2012-11-04 16:14
2012-08-16 16:59
2012-08-15 14:02
2012-07-19 09:51
2012-07-16 16:36
2012-07-04 15:48
2012-07-04 14:16
2012-07-04 11:36
2012-07-03 18:49
2012-07-03 16:17
2012-06-27 15:33