前台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); //使用坐标,直接标地图位置。
};
}
}