Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
网站模板中加入google地图代码,如何传递变量?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
mining  
View profile   Translate to Translated (View Original)
 More options Nov 4, 5:31 am
From: mining <mine....@gmail.com>
Date: Wed, 4 Nov 2009 02:31:42 -0800 (PST)
Local: Wed, Nov 4 2009 5:31 am
Subject: 网站模板中加入google地图代码,如何传递变量?
我的网站是静态页面的,每个静态页面都是由一个模板来生成的。

模板文件中,公司名称的显示方式代码如下:

<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&amp;v=2&amp;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]这个变量放到上述的代码中实现地址解析?


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
illumin  
View profile   Translate to Translated (View Original)
 More options Nov 4, 10:16 pm
From: illumin <illumi...@gmail.com>
Date: Wed, 4 Nov 2009 19:16:00 -0800 (PST)
Subject: Re: 网站模板中加入google地图代码,如何传递变量?
showAddress("大河工业园丽友路2号  保定市容城县, 河北 071700
China"); 这句就是解析地址啊,你难道想让google解析你的公司名...

On Nov 4, 6:31 pm, mining <mine....@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fei Chen  
View profile   Translate to Translated (View Original)
 More options Nov 6, 5:24 am
From: Fei Chen <phinix.c...@gmail.com>
Date: Fri, 6 Nov 2009 18:24:04 +0800
Local: Fri, Nov 6 2009 5:24 am
Subject: Re: 网站模板中加入google地图代码,如何传递变量?

应该是在你的php页面里面使用形如var name = <? echo($news[subject])?>这样的写法就可以吧
我没用过php,建议你看一下php相关的内容

2009/11/5 illumin <illumi...@gmail.com>


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dorian  
View profile   Translate to Translated (View Original)
 More options Nov 15, 1:47 am
From: Dorian <leedor...@gmail.com>
Date: Sat, 14 Nov 2009 22:47:59 -0800 (PST)
Local: Sun, Nov 15 2009 1:47 am
Subject: Re: 网站模板中加入google地图代码,如何传递变量?
new GInfoWindowTab('地址','$news[subject]')
... ...
showAddress("<?php echo $news[subject];?>");

On 11月4日, 下午6时31分, mining <mine....@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google