Maps JavaScript API 还支持双向 (Bidi) 文本,即本身同时包含从左到右 (LTR) 和从右到左 (RTL) 语言字符的文本。
通常,您应当将 dir=‘rtl’ 添加到网页的 元素中,以指定要正确呈现的 RTL 语言网页。
以下示例呈现了一张采用汉语控件的波士顿地图:
![]()
程序源代码:[code]
OSSEZ Google Maps JavaScript API v3 Example: 双向文本 html, body { height: 100%; margin: 0; padding: 0; } #map_canvas { height: 100%; } @media print { html, body { height: auto; } #map_canvas { height: 650px; } } function initialize() { var mapOptions = { scaleControl: true, center: new google.maps.LatLng(42.313431516450144, -71.05715705), zoom: 10, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
var marker = new google.maps.Marker({
map: map,
position: map.getCenter()
});
var infowindow = new google.maps.InfoWindow();
infowindow.setContent('<b>双向文本</b>');
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
波士顿 Boston
[/code]