> showAddress("大河工业园丽友路2号 保定市容城县, 河北 071700
> China"); 这句就是解析地址啊,你难道想让google解析你的公司名...
> On Nov 4, 6:31 pm, mining <mine....@gmail.com> wrote:
> > 我的网站是静态页面的,每个静态页面都是由一个模板来生成的。
> > 模板文件中,公司名称的显示方式代码如下:
> > <h1>$news[subject]</h1>
> > 其中,$news[subject] 代表者公司的名称,每个生成的静态页面公司的名称都是不同的。
> > 现在想要通过修改模板加入google地图代码,让每个页面根据公司的名称来显示公司在google地图中的位置。
> > 这种方式要求访客在打开页面的时候,无需用户动手,google地图自动根据从$news[subject]获得的值,也就是公司名称显示该公司在地图
> > 上的位置。
> > 找到了一个网站,看见其能实现此种要求,网址:
> > http://xn--fiqs8sul1dtjf.net/%E7%BE%8E%E6%96%AF%E7%89%B9%E7%BD%97---%...
> > http://xn--fiqs8sul1dtjf.net/%E6%88%90%E9%83%BD%E9%98%B2%E8%BE%90%E5%...
> > 以上这两个网址就是这个网站上两个静态页面自动显示公司位置的例子,我精简了其中的google地图代码如下
> > header中的代码
> > </script><script src="http://maps.google.com/maps?
> file=api&v=2&key=ABQIAAAA3yQdOWLCyutH1iSgviACSRRpyXdsl6qUn4PiK7Vw0v s-
> > rtXVNxSB2s0WW3na4SoZ6YWOGbutHQiXDw" type="text/javascript"></script>
> > <script type="text/javascript">
> > var map = null;
> > var geocoder = null;
> > function load() {
> > if (GBrowserIsCompatible()) {
> > geocoder = new GClientGeocoder();
> > function showAddress(address) {
> > if (geocoder) {
> > geocoder.getLatLng(
> > address,
> > function(point) {
> > if (!point) {
> > document.getElementById
> > ("map").style.display="none";
> > } else {
> > map = new GMap2(document.getElementById
> > ("map"));
> > map.setCenter(new GLatLng(37.4419,
> > -122.1419), 13);
> > map.addControl(new GSmallMapControl
> > ());
> > map.setCenter(point, 13);
> > var marker = new GMarker(point);
> > var infoTabs = [
> > new GInfoWindowTab('地址','<b>美斯特罗---华菱
> > 制衣有限公司</b><br>大河工业园丽友路2号 <br>保定市容城县, 河北,
> > 071700<br>China<br>'),
> > new GInfoWindowTab('Directions',
> > 'Enter your address:<br><form action="http://maps.google.com/maps"
> > method="get" target="_blank"><input type="text" size="40"
> > maxlength="60" name="saddr" id="saddr" value=""><br><input
> > class="button" value="Get Directions" type="submit"><input
> > type="hidden" name="daddr" value="大河工业园丽友路2号 +保定市容城县+河北+China"></
> > form>')];
> > GEvent.addListener(marker, 'click',
> > function() {
> > marker.openInfoWindowTabsHtml
> > (infoTabs);
> > });
> > map.addOverlay(marker);
> > marker.openInfoWindowTabsHtml(infoTabs);
> > }
> > }
> > );
> > }
> > }
> > showAddress("大河工业园丽友路2号 保定市容城县, 河北 071700
> > China");
> > }
> > }
> > </script>
> > body中的代码
> > <div id="map" style="width: 350px; height: 250px"></div>
> > 现在的问题是我不知道该如何才能把$news[subject]这个变量放到上述的代码中实现地址解析?