要想在自己的网站上用google地图展示出地址,就的用到 google map api ,如下,其中address是最重要的,
- <script src= "http://maps.google.com/maps?file=api&v=2&key=${mapkey()}"
- type="text/javascript" ></script>
- <script language="javascript" >
- var orgName = '<@s.property value="orgInfoDetail.orgName" />' ;
- var phone = '<@s.property value="orgInfoDetail.phone" />' ;
- var address = '<@s.property value="orgInfoDetail.address" />' ;
- // 弹出信息
- var popInfo = "<B>" + orgName + "</B><BR>" + phone + "<BR>" + address;
- var map = null ;
- var geocoder = null ;
- function load() {
- if (GBrowserIsCompatible()) {
- map = new GMap2(document.getElementByIdx_x( "map" ));
- //添加一个控制条
- map.addControl(new GSmallMapControl());
- geocoder = new GClientGeocoder();
- showAddress();
- }
- }
- function showAddress() {
- if (geocoder) {
- geocoder.getLatLng(address,
- function(point) {
- if (!point) {
- //alert(address + " 找不到该地址,无法显示地图!");
- } else {
- map.setCenter(point, 14 );
- var marker = new GMarker(point);
- map.addOverlay(marker);
- marker.openInfoWindowHtml(popInfo);
- }
- });
- }
- }
- </script>
在html载入的时候就执行,那么就是
- <body οnlοad= "load()" >
转载自:http://tsaowe.iteye.com/blog/1000400