怎样利用google map给在自己的网站上加上清晰的地图标识。
要想在自己的网站上用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>
<body onload="load()" >