如何获得谷歌handle_geolocation_query地图显示方向从用户的位置
How to get google handle_geolocation_query map to display directions from users location
var endlocation = {
'center': '52.5606064,2.0312582999999904',
'zoom': 10
};
var start = navigator.geolocation.getCurrentPosition(handle_geolocation_query);
var themap;
var destination = "Wednesbury, WS10 7TB";
$(document).ready(function () {
$('#map').gmap({
'center': endlocation.center,
'zoom': endlocation.zoom,
'disableDefaultUI': true,
'callback': function () {
themap = this;
$('#submit').click(function () {
themap.displayDirections({
'origin': start,
'destination': destination,
'travelMode': google.maps.DirectionsTravelMode.DRIVING,
'unitSystem': google.maps.UnitSystem.IMPERIAL
}, {
'panel': document.getElementById('directions')
},
function (response, status) {
(status === 'OK') ? $('#results').show() : $('#results').hide();
});
return false;
});
}
});
navigator.geolocation.getCurrentPosition(handle_geolocation_query);
});
function handle_geolocation_query(position) {
start = new google.maps.LatLng(lat, lon);
themap.get('map').panTo(start);
}
我似乎无法弄清楚我应该传递给handle_geolocation_query来获取地图从用户位置到固定点的指示。提前感谢任何帮助,对不起,我是一个新手的地图。这里是html:
<div id="map" style="height:500px;"><div>
如果您的其余代码正常工作,这应该与提交相同,但会在运行handle_geolocation_query函数时自动执行。
function handle_geolocation_query(position) {
start = new google.maps.LatLng(lat, lon);
themap.displayDirections({
'origin': start,
'destination': destination,
'travelMode': google.maps.DirectionsTravelMode.DRIVING,
'unitSystem': google.maps.UnitSystem.IMPERIAL
}, {
'panel': document.getElementById('directions')
},
function (response, status) {
(status === 'OK') ? $('#results').show() : $('#results').hide();
});
});
相关文章:
- ng映射方向备选方案
- 从远程脚本获取用户IP
- 如何通过自己获得Chrome扩展的用户反馈/错误报告
- d3基于用户选择动态更新节点
- 同步调用,直到用户通过angular验证为访问者
- RubyonRails——构建交互式接口应该朝哪个方向发展
- 需要帮助谷歌地图方向面板在FancyBox中显示
- 使用javascript搜索具有用户输入的数组
- 如何使用jquery确定用户是否年满18岁
- Meteor-添加用户自定义字段的方法不起作用
- React Native通过Navigator将用户输入数据传递到选项卡栏IOS中的组件
- 跟踪用户点击Adsense广告的IP地址
- 使用javascript反复检查用户在facebook上的登录状态
- 我想在AngularJS应用程序中创建一个输入数字框,用户不应该在该框上键入十进制数字.(一个整数输入框)
- 如何检查用户在html5视频播放器中观看了完整的视频
- 我怎样才能知道用户滑动的方向
- 如何使谷歌地图V3方向工作与用户位置检测-GeoCoder
- 如何获得谷歌handle_geolocation_query地图显示方向从用户的位置
- 当用户想要改变手机方向时,我的应用显示错误的UI.Android
- jQuery 滑块“slide”事件:如何确定用户的幻灯片方向