【发布时间】:2012-08-19 00:33:28
【问题描述】:
你好希望有人能帮我解决这个问题
我有一张来自 Json 文件的动态数据的地图 json 中的数据字段是 [[LAT]] [[LONG]]
我想要做的是,如果 json 文件没有发送任何值,则必须关闭 mapcontainer div。到目前为止,我没有工作。
这里是javascript:
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(50.892374,5.992003);
var myOptions = {
zoom: 15,
streetViewControl: true,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
if (latlng !== "50.892374" , "5.992003000000068"){
alert(latlng)
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
else{
alert("hide mapcontainer div")
document.getElementById("mapcontainer").style.visibility = 'none';
}
}
</script>
问题是,无论我做什么,latlng 永远不会等于我在示例中给出的值。
这是我要关闭的 div:
<div class="mapcontainer" id="mapcontainer">
<div class="themap">
<div id="map_canvas" style="width:100; height:200px;"></div>
</div>
</div>
在我的实际工作中,latlng 看起来像这样: var latlng = new google.maps.LatLng([[LAT]],[[LONG]]);
提前感谢您的帮助
【问题讨论】:
标签: javascript