forked from onury/geolocator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Onur YILDIRIM
committed
Jan 9, 2015
1 parent
3bb627b
commit 3957f94
Showing
4 changed files
with
60 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/*jslint browser:true, nomen:true */ | ||
/*jslint browser:true, nomen:true, regexp:true, unparam:true */ | ||
/*global google:false */ | ||
|
||
|
||
/** @license Geolocator Javascript Lib v.1.2.4 | ||
/** @license Geolocator Javascript Lib v.1.2.6 | ||
* (c) 2014-2015 Onur Yildirim ([email protected]) | ||
* https://github.com/onury/geolocator | ||
* MIT License | ||
|
@@ -70,7 +70,8 @@ var geolocator = (function () { | |
} | ||
|
||
script.onerror = function (e) { | ||
execCb(onError, 'Could not load source at ' + String(url).replace(/\?.*$/, '')); | ||
var errMsg = 'Could not load source at ' + String(url).replace(/\?.*$/, ''); | ||
execCb(onError, new Error(errMsg)); | ||
}; | ||
|
||
script.src = url; | ||
|
@@ -188,12 +189,12 @@ var geolocator = (function () { | |
function getPosition(fallbackToIP, html5Options) { | ||
geolocator.location = null; | ||
|
||
function fallback(errMsg) { | ||
function fallback(error) { | ||
var ipsIndex = fallbackToIP === true ? 0 : (typeof fallbackToIP === 'number' ? fallbackToIP : -1); | ||
if (ipsIndex >= 0) { | ||
geolocator.locateByIP(onSuccess, onError, ipsIndex, mCanvasId); | ||
} else { | ||
if (onError) { onError(errMsg); } | ||
if (onError) { onError(error); } | ||
} | ||
} | ||
|
||
|
@@ -207,13 +208,13 @@ var geolocator = (function () { | |
} | ||
|
||
function geoError(error) { | ||
fallback(error.message); | ||
fallback(error); | ||
} | ||
|
||
if (navigator.geolocation) { | ||
navigator.geolocation.getCurrentPosition(geoSuccess, geoError, html5Options); | ||
} else { // not supported | ||
fallback('geolocation is not supported.'); | ||
fallback(new Error('geolocation is not supported.')); | ||
} | ||
} | ||
|
||
|
@@ -300,7 +301,7 @@ var geolocator = (function () { | |
if (initialized === true) { | ||
finalize(geolocator.location.coords); | ||
} else { | ||
if (onError) { onError(data || 'Could not get location.'); } | ||
if (onError) { onError(new Error(data || 'Could not get location.')); } | ||
} | ||
} | ||
|
||
|
@@ -352,6 +353,13 @@ var geolocator = (function () { | |
mCanvasId = mapCanvasId; | ||
geolocator.__ipscb = onGeoSourceCallback; | ||
loadIpGeoSource(ipGeoSources[sourceIndex]); | ||
}, | ||
|
||
/** Checks whether the type of the given object is HTML5 | ||
* `PositionError` and returns a `Boolean` value. | ||
*/ | ||
isPositionError: function (error) { | ||
return Object.prototype.toString.call(error) === '[object PositionError]'; | ||
} | ||
}; | ||
}()); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.