回复: 很奇怪的一个问题,设置的变量值被清空掉了。

0 views
Skip to first unread message

owen42087743

unread,
Jan 17, 2010, 10:17:31 AM1/17/10
to google-maps-api-china
人家写得已经很明确了,错误就是if ((h_lat=="")||(h_lng=""))把后面的-换成==啊.
 
 
------------------ 原始邮件 ------------------
发件人: "miya tang"<miya...@gmail.com>;
发送时间: 2010年1月17日(星期天) 晚上10:06
收件人: "google-maps-api-china"<google-map...@googlegroups.com>;
主题: Re: 很奇怪的一个问题,设置的变量值被清空掉了。
 
天,看了半天也没看出来,多个编程语言间转换时,真是很郁闷。
谢谢 帮忙。


2010/1/17 秦志坚 <qin...@gmail.com>
将赋值符号=换为==即可

2010/1/17 miya tang <miya...@gmail.com>
前台HTML中,有初始货变量值。

<script type="text/javascript">
//赋值,把酒店信息传到JS代码中。
var centerLatitude="31.2281421862";
var centerLongitude="121.4757013321";
var h_id="1";
var h_lat="31.2281421862";
var h_lng="121.4757013321";
var h_addr="上海市黄浦区人民大道201号";
var h_name="上海博物馆";
var h_city="上海";
alert("h_lng="+h_lng);
</script>
<script src="h_show_map_files/googlemap.js" type="text/javascript"></script>

调用的JS中,有判断值是否正常。
前面都显示正常。
到 if ((h_lat=="")||(h_lng=""))
判断后,h_lng 值被清空掉了。
到底是什么原因,我在其它地方,没有再用到此变量,
也没有加载其它JS 文件。

很奇怪。


我要实现的功能是,如果没有设置一个地理位置的坐标,就使用地址来搜索
地图位置。



function init() {
if (GBrowserIsCompatible()) {

map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);
//如果没有设置具体的位置坐标,则查找地址,显示地理位置。
alert("h_lat="+h_lat+"/h_lng="+h_lng);
if ((h_lat=="")||(h_lng=""))
{showAddress(h_addr,h_name,h_city); //使用地址找到具体地图位置
}else{
alert("TEST h_lat="+h_lat+"/h_lng="+h_lng);
showmarker(h_lat,h_lng,h_id,h_name,h_addr); //使用坐标,直接标地图位置。
};
}
}

--
您收到此信息是由于您订阅了 Google 论坛“谷歌地图 API 中文论坛”论坛。
要在此论坛发帖,请发电子邮件到 Google-Map...@googlegroups.com
要退订此论坛,请发邮件至 Google-Maps-API-...@googlegroups.com
更多选项,请通过 http://groups.google.com/group/Google-Maps-API-China?hl=zh-CN 访问该论坛
什么是Google地图API? 请通过 http://code.google.com/intl/zh-CN/apis/maps/index.html 免费将 Google 地图嵌入自己的网页中



--
Best Regards
Daniel Qin

--
您收到此信息是由于您订阅了 Google 论坛“谷歌地图 API 中文论坛”论坛。
要在此论坛发帖,请发电子邮件到 Google-Map...@googlegroups.com
要退订此论坛,请发邮件至 Google-Maps-API-...@googlegroups.com
更多选项,请通过 http://groups.google.com/group/Google-Maps-API-China?hl=zh-CN 访问该论坛
什么是Google地图API? 请通过 http://code.google.com/intl/zh-CN/apis/maps/index.html 免费将 Google 地图嵌入自己的网页中

miya tang

unread,
Jan 17, 2010, 10:05:18 PM1/17/10
to google-map...@googlegroups.com
 问题昨天已解决,谢谢 各位帮忙.JS 用得不多的原因.

2010/1/17 owen42087743 <owen42...@gmail.com>
Reply all
Reply to author
Forward
0 new messages