1
我有一个div移动页面,用于构建应用程序。当我定义:JQuery Mobile无法将GPS坐标拖入Google地图
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
无论是在我的功能,甚至外面,然后尝试和使用它们:
latlng1 = new google.maps.LatLng(latitude, longitude);
我的页面没有加载,并且只给了我的CSS边框等
但是,如果我只是删除(latitude, longitude);
并将(40.716948, -74.003563);
纳入latlng1 = new google.maps.LatLng(40.716948, -74.003563);
它的工作原理。
为什么定义的变量值不会传入LatLng?
这里是源的DIV部分:
<!-- My Location -->
<div data-role="page" data-theme="b" id="my_loc" class="page-map1">
<div data-role="header" data-theme="a">
<a href="#home" data-icon="arrow-l">Back</a>
<h1>My Location</h1>
</div>
<div data-role="content">
<h2>Map</h2>
<div id="map1" class="gmap"></div>
<script type="text/javascript">
var map1, latlng1, options1, latitude, longitude;
//these lat and long variable definitions are messing me up !!
//latitude = position.coords.latitude;
//longitude = position.coords.longitude;
function initialize() {
latlng1 = new google.maps.LatLng(latitude, longitude);
//40.716948, -74.003563);
//Lat, Lon);
//(position.coords.latitude, position.coords.longitude);
//40.716948, -74.003563); change from new jersey
options1 = { zoom: 14, center: latlng1, mapTypeId:google.maps.MapTypeId.ROADMAP };
map1 = new google.maps.Map(document.getElementById("map1"), options1);
}
$('.page-map1').live("pagecreate", function() {
initialize();
});
$('.page-map1').live('pageshow',function(){
console.log("test");
google.maps.event.trigger(map1, 'resize');
map1.setOptions(options1);
});
</script>
</div>
</div>
<div data-role="page" id="map" data-theme="a">
<div data-role="header" data-position="fixed">
<h1>Page Header</h1>
</div>
<div data-role="content">
<p class="errorMsg">Your location could not be determined.</p>
<div id="gMap"></div>
</div>
<div data-role="footer" data-position="fixed">
<h4>TRACK</h4>
</div>
</div>
<!-- /My Location -->
</div>
你可以修复'输入代码在这里吗? –
我不是一个jquery的家伙,也不了解你想要做的事情,但它确实看起来像你设置'纬度'和'经度'的值被注释掉了。 –