HTML5 地理定位无 SSL 连接
HTML5 地理定位用于查找用户的地理位置。这是无需 SSL 连接的。可按如下方式生成 -
// Variable apigeo shows successful location: var apigeo = function(position) { alert("API geolocation success!
lat = " + position.coords.latitude + "
lng = " + position.coords.longitude); }; var tryapigeo = function() { jQuery.post( "check the location on google map", function(success) { apiGeolocationSuccess({coords: {latitude: success.location.lat, longitude: success.location.lng}}); }) //Gives success on given geolocation .failure(function(err) { //On failure, alert with failure is shown alert("error while showing geolocation!
"+err); }); };
然后可生成错误代码的各种开关情况,不同的错误对应不同的错误代码。
var tryloc = function() {//tryloc variable show current position if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( browserGeolocationSuccess, browserGeolocationFail,{ maximumAge: 70000, timeout: 40000, enableHighAccuracy: true}); / /this will show result with high accuracy }};
广告