{"version":3,"sources":["webpack://geolocator/webpack/universalModuleDefinition","webpack://geolocator/webpack/bootstrap","webpack://geolocator/./src/core/enums.js","webpack://geolocator/./src/core/geo.error.js","webpack://geolocator/./src/core/geo.helper.js","webpack://geolocator/./src/core/geo.watcher.js","webpack://geolocator/./src/core/geolocator.js","webpack://geolocator/./src/index.js","webpack://geolocator/./src/lib/fetch.js","webpack://geolocator/./src/lib/utils.js"],"names":["GOOGLE_MAPS_API_BASE","enums","Object","freeze","URL","IP","FLAG","GOOGLE_MAPS_API","GOOGLE_SATATIC_MAP","GOOGLE_GEOLOCATION","GOOGLE_GEOCODE","GOOGLE_TIMEZONE","GOOGLE_DISTANCE_MATRIX","MapTypeId","HYBRID","ROADMAP","SATELLITE","TERRAIN","LocationType","ROOFTOP","RANGE_INTERPOLATED","GEOMETRIC_CENTER","APPROXIMATE","TravelMode","DRIVING","WALKING","BICYCLING","TRANSIT","UnitSystem","METRIC","IMPERIAL","RadioType","LTE","GSM","CDMA","WCDMA","DistanceFormula","HAVERSINE","PYTHAGOREAN","ImageFormat","PNG","PNG_8","PNG_32","GIF","JPG","JPG_BASELINE","GeoError","code","Code","UNKNOWN_ERROR","message","String","defineProperty","enumerable","writable","value","Error","hasOwnProperty","captureStackTrace","constructor","stack","err","msg","utils","isPositionError","PERMISSION_DENIED","POSITION_UNAVAILABLE","TIMEOUT","isValidErrorCode","response","INVALID_RESPONSE","errCode","isString","errorCodeFromStatus","isObject","errMsg","error_message","errorMessage","error","status","reason","errors","isArray","length","errorCodeFromReason","errorCode","prop","prototype","toString","name","setPrototypeOf","create","GEOLOCATION_NOT_SUPPORTED","INVALID_GEO_IP_SOURCE","INVALID_PARAMETERS","INVALID_REQUEST","REQUEST_DENIED","REQUEST_FAILED","GOOGLE_API_FAILED","OVER_QUERY_LIMIT","USER_RATE_LIMIT_EXCEEDED","DAILY_LIMIT_EXCEEDED","GOOGLE_KEY_INVALID","MAX_ELEMENTS_EXCEEDED","MAX_DIMENSIONS_EXCEEDED","MAX_WAYPOINTS_EXCEEDED","PARSE_ERROR","NOT_FOUND","INTERNAL_ERROR","geoHelper","toGoogleCoords","coords","lat","latitude","lng","longitude","fromGoogleCoords","toPointList","arr","map","o","getGeocodeComps","comp","route","locality","administrative_area","administrativeArea","postal_code","postalCode","country","region","buildGeocodeParams","options","reverse","params","e","encodeURI","placeId","push","address","geoComps","operator","separator","b","bounds","isPlainObject","keys","southwestLat","southwestLng","northeastLat","northeastLng","language","key","join","formatGeocodeResults","results","location","formattedAddress","type","i","c","data","comps","address_components","types","long_name","short_name","geometry","commonName","point_of_interest","premise","subpremise","colloquial_area","streetNumber","street_number","street","administrative_area_level_4","administrative_area_level_3","neighborhood","administrative_area_level_5","town","sublocality","administrative_area_level_2","city","administrative_area_level_1","state","stateCode","administrative_area_level_1_s","countryCode","country_s","formatted_address","location_type","place_id","timestamp","time","geocode","conf","callback","opts","coordsSet","isNumber","extend","google","raw","query","url","setProtocol","https","xhrOpts","fetch","xhr","safeJsonParse","responseText","gErr","fromResponse","formatDistanceResults","origins","originAddresses","dests","destinationAddresses","rows","forEach","origin","oIndex","dest","dIndex","elements","from","to","distance","duration","fare","mapStylesToParams","styles","result","v","a","style","stylers","featureType","elementType","val","propName","propVal","replace","encodeURIComponent","GeoWatcher","onChange","onError","isCleared","cycle","_timer","id","navigator","geolocation","watchPosition","isFunction","pos","clearOnError","clear","clearWatch","delay","d","cb","clearTimeout","_clear","setTimeout","EARTH_RADIUS_KM","EARTH_RADIUS_MI","defaultConfig","version","geolocator","_","config","center","getStaticMap","mapTypeId","size","width","height","scale","zoom","marker","format","color","getStyles","element","title","undefined","elem","document","getElementById","isJQueryObject","isGoogleLoaded","maps","Map","getDiv","isElement","isNode","ensureGoogleLoaded","mapData","configCreateMap","enableHighAccuracy","timeout","maximumWait","maximumAge","desiredAccuracy","onProgress","noop","fallbackToIP","addressLookup","timezone","staticMap","checkGoogleKey","callbackMap","locateByIP","onPositionReceived","fetchAddressAndTimezone","onPositionError","isGeolocationSupported","locateAccurate","getCurrentPosition","homeMobileCountryCode","homeMobileNetworkCode","radioType","carrier","cellTowers","wifiAccessPoints","considerIp","headers","JSON","stringify","post","getXHRResponse","isGeoError","accuracy","source","geoIpSource","updateResponse","schema","mapToSchema","provider","setLocationURLs","Number","async","get","parse","callbackParam","globalVar","jsonpOpts","clean","rootName","jsonp","window","clone","isStringSet","watcher","target","radius","unitSystem","onPositionChanged","own","calcDistance","formula","targetReached","reverseGeocode","timeZoneId","timeZoneName","abbr","dots","dstOffset","rawOffset","destinations","destination","invalidOriginOrDest","travelMode","avoidFerries","avoidHighways","avoidTolls","service","DistanceMatrixService","getDistanceMatrix","DistanceMatrixStatus","OK","dLat","degToRad","dLng","Math","sin","cos","atan2","sqrt","latA","latB","lngA","lngB","x","y","ip","k","obj","km","mi","degrees","PI","radians","dec","isLng","sign","sn","we","nsew","absValue","abs","round","floor","getMapOpts","mapOptions","_geolocatorMapData","instance","infoWindow","LatLng","setOptions","Marker","event","clearInstanceListeners","setMap","position","InfoWindow","setContent","addListener","open","cc","flag","toLowerCase","createMap","loc","getTZ","getTimeZone","complete","watch","isFilledArray","setGeoIPSource","require","module","exports","defer","trim","script","createElement","cbParamSet","cbFnName","root","rootNameSet","randomString","qMark","indexOf","execCb","timeUp","parentNode","removeChild","fn","notateGlobalObj","readyState","onreadystatechange","onload","onerror","removeQuery","charset","crossorigin","src","getElementsByTagName","appendChild","isXDR","XMLHttpRequest","XDomainRequest","hasCallback","method","withCredentials","mimeType","username","password","toUpperCase","xError","crossDomain","XHR_READY_STATE","DONE","ontimeout","setRequestHeader","overrideMimeType","send","_xhr","UNSENT","OPENED","HEADERS_RECEIVED","LOADING","_toString","Boolean","call","array","isDate","object","HTMLElement","nodeType","Node","jQuery","isError","str","removeProtocol","p","protocol","trimDots","decodeURI","decodeURIComponent","len","random","slice","upper","s","match","encode","include","exclude","inc","exc","forIn","notation","levels","split","shift","note","sources","concat","Date","cloned","mapped","seconds","ts","now","parseInt"],"mappings":";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F,MAAMqR,WAAN,CAAkB4D,GAAlB,EAAuBzV,KAAvB,CAAd;AACH,aAFD,MAEO;AACHge,uBAAO/X,GAAP,IAAcwP,IAAIzV,KAAJ,CAAd;AACH;AACJ,SAND;AAOA,eAAOge,MAAP;AACH,KAvfS;;;AAyfV;AACA;AACA;;AAEA;;;;;;;;;;AAUApU,iBAvgBU,yBAugBIwS,GAvgBJ,EAugBS;AACf,YAAInY,IAAI,IAAR;AACA,YAAI;AACAA,gBAAIkN,KAAKgB,KAAL,CAAWiK,GAAX,CAAJ;AACH,SAFD,CAEE,OAAOpX,CAAP,EAAU,CAAE;AACd,eAAOf,CAAP;AACH,KA7gBS;;;AA+gBV;;;;;;;;;;;;AAYA0E,QA3hBU,gBA2hBLsV,OA3hBK,EA2hBI;AACV,YAAIC,KAAKJ,KAAKK,GAAL,EAAT;AACA,eAAOF,UAAUG,SAASF,KAAK,IAAd,EAAoB,EAApB,CAAV,GAAoCA,EAA3C;AACH;AA9hBS,CAAd;;AAkiBA,+DAAe1d,KAAf,E","file":"geolocator.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"geolocator\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"geolocator\"] = factory();\n\telse\n\t\troot[\"geolocator\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"dist/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.js\");\n","const GOOGLE_MAPS_API_BASE = '//maps.googleapis.com/maps/api';\n\n/**\n * This file only includes partial documentation about `geolocator` enumerations.\n * Note that these enumerations are mostly an aggregation of\n * {@link https://developers.google.com/maps/documentation/javascript|Google Maps API} constants.\n *\n * @private\n * @readonly\n */\nconst enums = Object.freeze({\n /**\n * Enumerates API endpoints used within Geolocator core.\n *\n * @enum {String}\n * @readonly\n * @private\n */\n URL: {\n /**\n * Public IP retrieval (free) service.\n * @type {String}\n * @private\n */\n IP: '//api.ipify.org',\n /**\n * Country SVG flags.\n * e.g. /tr.svg for Turkey flag.\n * @type {String}\n * @private\n */\n FLAG: '//cdnjs.cloudflare.com/ajax/libs/flag-icon-css/2.3.1/flags/4x3/',\n /**\n * Google Maps API bootstrap endpoint that loads all of the main\n * Javascript objects and symbols for use in the Maps API.\n * Some Maps API features are also available in self-contained\n * libraries which are not loaded unless you specifically request them.\n * See {@link https://developers.google.com/maps/documentation/javascript/libraries|details}.\n * @type {String}\n * @private\n */\n GOOGLE_MAPS_API: GOOGLE_MAPS_API_BASE + '/js',\n /**\n * Google Maps API Static Map endpoint.\n * @type {String}\n * @private\n */\n GOOGLE_SATATIC_MAP: GOOGLE_MAPS_API_BASE + '/staticmap',\n /**\n * Google Geolocation API endpoint.\n * @type {String}\n * @private\n */\n GOOGLE_GEOLOCATION: '//www.googleapis.com/geolocation/v1/geolocate',\n /**\n * Google Geocode API endpoint.\n * @type {String}\n * @private\n */\n GOOGLE_GEOCODE: '//maps.googleapis.com/maps/api/geocode/json',\n /**\n * Google TimeZone API endpoint.\n * @type {String}\n * @private\n */\n GOOGLE_TIMEZONE: '//maps.googleapis.com/maps/api/timezone/json',\n /**\n * Google Distance Matrix API endpoint.\n * @type {String}\n * @private\n */\n GOOGLE_DISTANCE_MATRIX: '//maps.googleapis.com/maps/api/distancematrix/json'\n },\n /**\n * Enumerates Google map types.\n * @memberof! geolocator\n *\n * @enum {String}\n * @readonly\n */\n MapTypeId: {\n /**\n * Map type that displays a transparent layer of major streets on\n * satellite images.\n * @type {String}\n */\n HYBRID: 'hybrid',\n /**\n * Map type that displays a normal street map.\n * @type {String}\n */\n ROADMAP: 'roadmap',\n /**\n * Map type that displays satellite images.\n * @type {String}\n */\n SATELLITE: 'satellite',\n /**\n * Map type displays maps with physical features such as terrain and\n * vegetation.\n * @type {String}\n */\n TERRAIN: 'terrain'\n },\n /**\n * Enumerates Google location types.\n * @memberof! geolocator\n *\n * @enum {String}\n * @readonly\n */\n LocationType: {\n /**\n * Indicates that the returned result is a precise geocode for which\n * we have location information accurate down to street address\n * precision.\n * @type {String}\n */\n ROOFTOP: 'ROOFTOP',\n /**\n * Indicates that the returned result reflects an approximation\n * (usually on a road) interpolated between two precise points (such as\n * intersections). Interpolated results are generally returned when\n * rooftop geocodes are unavailable for a street address.\n * @type {String}\n */\n RANGE_INTERPOLATED: 'RANGE_INTERPOLATED',\n /**\n * Indicates that the returned result is the geometric center of a\n * result such as a polyline (for example, a street) or polygon\n * (region).\n * @type {String}\n */\n GEOMETRIC_CENTER: 'GEOMETRIC_CENTER',\n /**\n * Indicates that the returned result is approximate.\n * @type {String}\n */\n APPROXIMATE: 'APPROXIMATE'\n },\n /**\n * Enumerates Google travel modes.\n * @memberof! geolocator\n *\n * @enum {String}\n * @readonly\n */\n TravelMode: {\n /**\n * Indicates distance calculation using the road network.\n * @type {String}\n */\n DRIVING: 'DRIVING',\n /**\n * Requests distance calculation for walking via pedestrian paths &\n * sidewalks (where available).\n * @type {String}\n */\n WALKING: 'WALKING',\n /**\n * Requests distance calculation for bicycling via bicycle paths &\n * preferred streets (where available).\n * @type {String}\n */\n BICYCLING: 'BICYCLING',\n /**\n * Requests distance calculation via public transit routes (where\n * available). This value may only be specified if the request includes\n * an API key or a Google Maps APIs Premium Plan client ID. If you set\n * the mode to transit you can optionally specify either a\n * `departureTime` or an `arrivalTime`. If neither time is specified,\n * the `departureTime` defaults to now (that is, the departure time defaults\n * to the current time). You can also optionally include a `transitMode`\n * and/or a `transitRoutingPreference`.\n * @type {String}\n */\n TRANSIT: 'TRANSIT'\n },\n // /**\n // * Enumerates Google route restrictions.\n // * @memberof! geolocator\n // *\n // * @enum {String}\n // * @readonly\n // */\n // RouteRestriction: {\n // TOLLS: 'tolls',\n // HIGHWAYS: 'highways',\n // FERRIES: 'ferries',\n // INDOOR: 'indoor'\n // },\n /**\n * Enumerates Google unit systems.\n * @memberof! geolocator\n *\n * @enum {Number}\n * @readonly\n */\n UnitSystem: {\n /**\n * Distances in kilometers and meters.\n * @type {Number}\n */\n METRIC: 0,\n /**\n * Distances defined in miles and feet.\n * @type {Number}\n */\n IMPERIAL: 1\n },\n /**\n * Enumerates mobile radio types.\n * @memberof! geolocator\n *\n * @enum {String}\n * @readonly\n */\n RadioType: {\n /**\n * LTE (Long-Term Evolution) mobile radio type.\n * @type {String}\n */\n LTE: 'lte',\n /**\n * GSM (Global System for Mobile Communications) mobile radio type.\n * @type {String}\n */\n GSM: 'gsm',\n /**\n * CDMA (Code division multiple access) mobile radio access technology.\n * @type {String}\n */\n CDMA: 'cdma',\n /**\n * Wideband CDMA mobile radio access technology.\n * @type {String}\n */\n WCDMA: 'wcdma'\n },\n /**\n * Enumerates formulas/algorithms for calculating the distance between two\n * lat/lng points.\n * @memberof! geolocator\n *\n * @readonly\n * @enum {String}\n *\n * @todo {@link https://en.wikipedia.org/wiki/Vincenty%27s_formulae|Vincenty's Formula}\n */\n DistanceFormula: {\n /**\n * Haversine formula for calculating the distance between two lat/lng points\n * by relating the sides and angles of spherical triangles.\n * @see {@link http://en.wikipedia.org/wiki/Haversine_formula|Haversine_formula}.\n * @type {String}\n */\n HAVERSINE: 'haversine',\n /**\n * Formula based on the Pythagoras Theorem for calculating the\n * distance between two lat/lng points on a Equirectangular projection\n * to account for curvature of the longitude lines.\n * @see {@link https://en.wikipedia.org/wiki/Pythagorean_theorem|Pythagorean_theorem}\n * @type {String}\n */\n PYTHAGOREAN: 'pythagorean'\n },\n /**\n * Enumerates the image formats used for getting static Google Map images.\n * @memberof! geolocator\n *\n * @readonly\n * @enum {String}\n */\n ImageFormat: {\n /**\n * Specifies the PNG image format.\n * Same as `PNG_8`.\n * @type {String}\n */\n PNG: 'png',\n /**\n * Specifies the 8-bit PNG image format.\n * Same as `PNG`.\n * @type {String}\n */\n PNG_8: 'png8',\n /**\n * Specifies the 32-bit PNG image format.\n * @type {String}\n */\n PNG_32: 'png32',\n /**\n * Specifies the GIF image format.\n * @type {String}\n */\n GIF: 'gif',\n /**\n * Specifies the JPEG compressed image format.\n * @type {String}\n */\n JPG: 'jpg',\n /**\n * Specifies a non-progressive JPEG compression image format.\n * @type {String}\n */\n JPG_BASELINE: 'jpg-baseline'\n }\n});\n\nexport default enums;\n","import utils from '../lib/utils';\n\n/**\n * Geolocator Error class that provides a common type of error object for the\n * various APIs implemented in Geolocator. All callbacks of Geolocator will\n * include an instance of this object as the first argument; if the\n * corresponding operation fails. Also all thrown errors will be an instance of\n * this object.\n *\n * This object can be publicly accessed via `geolocator.Error`.\n *\n * @extends Error\n */\nclass GeoError { // extends Error (doesn't work with transpilers)\n\n /**\n * Costructs a new instance of `GeoError`.\n *\n * @param {String} [code=\"UNKNOWN_ERROR\"]\n * Any valid Geolocator Error code.\n * See {@link #GeoError.Code|`GeoError.Code` enumeration} for\n * possible values.\n * @param {String} [message]\n * Error message. If omitted, this will be set to `code`.\n *\n * @returns {GeoError}\n *\n * @example\n * var GeoError = geolocator.Error,\n * error = new GeoError(GeoError.Code.GEOLOCATION_NOT_SUPPORTED);\n * console.log(error.code); // \"GEOLOCATION_NOT_SUPPORTED\"\n * console.log(error instanceof GeoError); // true\n */\n constructor(code = GeoError.Code.UNKNOWN_ERROR, message) {\n message = message || String(code);\n\n /**\n * Gets the name of the Error object.\n * This always returns `\"GeoError\"`.\n * @name GeoError#name\n * @type {String}\n */\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'GeoError' // this.constructor.name\n });\n\n /**\n * Gets the error code set for this instance.\n * This will return one of\n * {@link #GeoError.Code|`GeoError.Code` enumeration}.\n * @name GeoError#code\n * @type {String}\n */\n Object.defineProperty(this, 'code', {\n enumerable: false,\n writable: true,\n value: code\n });\n\n /**\n * Gets the error message set for this instance.\n * If no message is set, this will return the error code value.\n * @name GeoError#message\n * @type {String}\n */\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: message\n });\n\n if (Error.hasOwnProperty('captureStackTrace')) { // V8\n Error.captureStackTrace(this, this.constructor);\n } else {\n /**\n * Gets the error stack for this instance.\n * @name GeoError#stack\n * @type {String}\n */\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: (new Error(message)).stack\n });\n }\n }\n\n /**\n * Creates a new instance of `GeoError` from the given value.\n *\n * @param {*} [err]\n * Value to be transformed. This is used to determine the proper\n * error code for the created instance. If an `Error` or `Object` is\n * passed, its `message` property is checked if it matches any of the\n * valid error codes. If omitted or no match is found, error code\n * `GeoError.Code.UNKNOWN_ERROR` will be used as default.\n *\n * @returns {GeoError}\n *\n * @example\n * var GeoError = geolocator.Error,\n * \t error = GeoError.create();\n * console.log(error.code); // \"UNKNOWN_ERROR\"\n * error = GeoError.create(GeoError.Code.GEOLOCATION_NOT_SUPPORTED);\n * console.log(error.code); // \"GEOLOCATION_NOT_SUPPORTED\"\n */\n static create(err) {\n if (err instanceof GeoError) {\n return err;\n }\n\n let code, msg;\n\n if (utils.isPositionError(err) && err.code) {\n switch (err.code) {\n case 1:\n code = GeoError.Code.PERMISSION_DENIED;\n break;\n case 2:\n code = GeoError.Code.POSITION_UNAVAILABLE;\n break;\n case 3:\n code = GeoError.Code.TIMEOUT;\n break;\n default:\n code = GeoError.Code.UNKNOWN_ERROR;\n break;\n }\n return new GeoError(code, err.message || '');\n }\n\n if (typeof err === 'string') {\n code = msg = err;\n } else if (typeof err === 'object') {\n code = err.code || err.message;\n msg = err.message || err.code;\n }\n if (code && GeoError.isValidErrorCode(code)) {\n return new GeoError(code, msg);\n }\n\n return new GeoError(GeoError.Code.UNKNOWN_ERROR, msg);\n }\n\n /**\n * Creates a new instance of `GeoError` from the given response object.\n * Since Geolocator implements various Google APIs, we might receive\n * responses if different structures. For example, some APIs return a\n * response object with a `status:String` property (such as the TimeZone\n * API) and some return responses with an `error:Object` property. This\n * method will determine the correct reason or message and return a\n * consistent error object.\n *\n * @param {Object|String} response\n * Response (Object) or status (String) to be transformed.\n * @param {String} [message=null]\n * Error message.\n *\n * @returns {GeoError}\n * `GeoError` instance if response contains an error. Otherwise,\n * returns `null`.\n *\n * @example\n * var error = geolocator.Error.fromResponse(googleResponse);\n * console.log(error.code); // \"GOOGLE_KEY_INVALID\"\n */\n static fromResponse(response, message = '') {\n // example Google Geolocation API response:\n // https://developers.google.com/maps/documentation/geolocation/intro#errors\n // {\n // \"error\": {\n // \"errors\": [\n // {\n // \"domain\": \"global\",\n // \"reason\": \"parseError\",\n // \"message\": \"Parse Error\",\n // }\n // ],\n // \"code\": 400,\n // \"message\": \"Parse Error\"\n // }\n // }\n // example Google TimeZone API response:\n // {\n // \"status\": \"REQUEST_DENIED\"\n // }\n\n if (!response) return new GeoError(GeoError.Code.INVALID_RESPONSE);\n\n let errCode;\n\n if (utils.isString(response)) {\n errCode = errorCodeFromStatus(response);\n if (errCode) return new GeoError(errCode, message || response);\n }\n\n if (!utils.isObject(response)) return null;\n\n let errMsg = response.error_message\n || response.errorMessage\n || ((response.error && response.error.message) || '')\n || '';\n\n if (response.status) {\n errCode = errorCodeFromStatus(response.status);\n if (errCode) return new GeoError(errCode, errMsg || message || response.status);\n }\n\n if (response.error) {\n let reason = response.reason || response.error.reason;\n if (!reason) {\n let errors = response.error.errors;\n if (utils.isArray(errors) && errors.length > 0) {\n reason = errors[0].reason; // get the first reason only\n errMsg = errMsg || errors[0].message; // update errMsg\n }\n }\n errCode = errorCodeFromReason(reason) || GeoError.Code.UNKNOWN_ERROR;\n return new GeoError(errCode, errMsg || reason || message);\n }\n\n if (errMsg) {\n errCode = errorCodeFromStatus(errMsg) || GeoError.Code.UNKNOWN_ERROR;\n return new GeoError(errCode, errMsg || message);\n }\n\n return null;\n }\n\n /**\n * Checks whether the given value is an instance of `GeoError`.\n *\n * @param {*} err - Object to be checked.\n *\n * @returns {Boolean}\n */\n static isGeoError(err) {\n return err instanceof GeoError;\n }\n\n /**\n * Checks whether the given value is a valid Geolocator Error code.\n *\n * @param {String} errorCode - Error code to be checked.\n *\n * @returns {Boolean}\n */\n static isValidErrorCode(errorCode) {\n let prop;\n for (prop in GeoError.Code) {\n if (GeoError.Code.hasOwnProperty(prop)\n && errorCode === GeoError.Code[prop]) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * Gets the string representation of the error instance.\n *\n * @returns {String}\n */\nGeoError.prototype.toString = function () {\n var msg = this.code !== this.message ? ` (${this.message})` : '';\n return `${this.name}: ${this.code}${msg}`;\n};\n\n// `class x extends Error` doesn't work when using an ES6 transpiler, such as\n// Babel, since subclasses must extend a class. With Babel 6, we need\n// transform-builtin-extend plugin for this to work. So we're extending from\n// Error the old way. Now, `err instanceof Error` also returns `true`.\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(GeoError.prototype, Error.prototype);\n} else {\n GeoError.prototype = Object.create(Error.prototype);\n}\n\n// ---------------------------\n// ERROR CODES\n// ---------------------------\n\n/**\n * Enumerates Geolocator error codes.\n * This enumeration combines Google API status (error) codes, HTML5 Geolocation\n * position error codes and other Geolocator-specific error codes.\n * @enum {String}\n */\nGeoError.Code = {\n /**\n * Indicates that HTML5 Geolocation API is not supported by the browser.\n * @type {String}\n */\n GEOLOCATION_NOT_SUPPORTED: 'GEOLOCATION_NOT_SUPPORTED',\n /**\n * Indicates that Geolocation-IP source is not set or invalid.\n * @type {String}\n */\n INVALID_GEO_IP_SOURCE: 'INVALID_GEO_IP_SOURCE',\n /**\n * The acquisition of the geolocation information failed because the\n * page didn't have the permission to do it.\n * @type {String}\n */\n PERMISSION_DENIED: 'PERMISSION_DENIED',\n /**\n * The acquisition of the geolocation failed because at least one\n * internal source of position returned an internal error.\n * @type {String}\n */\n POSITION_UNAVAILABLE: 'POSITION_UNAVAILABLE',\n /**\n * The time allowed to acquire the geolocation, defined by\n * PositionOptions.timeout information was reached before\n * the information was obtained.\n * @type {String}\n */\n TIMEOUT: 'TIMEOUT',\n /**\n * Indicates that the request had one or more invalid parameters.\n * @type {String}\n */\n INVALID_PARAMETERS: 'INVALID_PARAMETERS',\n /**\n * Indicates that the service returned invalid response.\n * @type {String}\n */\n INVALID_RESPONSE: 'INVALID_RESPONSE',\n /**\n * Generally indicates that the query (address, components or latlng)\n * is missing.\n * @type {String}\n */\n INVALID_REQUEST: 'INVALID_REQUEST',\n /**\n * Indicates that the request was denied by the service.\n * This will generally occur because of a missing API key or because the request\n * is sent over HTTP instead of HTTPS.\n * @type {String}\n */\n REQUEST_DENIED: 'REQUEST_DENIED',\n /**\n * Indicates that the request has failed.\n * This will generally occur because of an XHR error.\n * @type {String}\n */\n REQUEST_FAILED: 'REQUEST_FAILED',\n /**\n * Indicates that Google API could not be loaded.\n * @type {String}\n */\n GOOGLE_API_FAILED: 'GOOGLE_API_FAILED',\n /**\n * Indicates that you are over your Google API quota.\n * @type {String}\n */\n OVER_QUERY_LIMIT: 'OVER_QUERY_LIMIT',\n /**\n * Indicates that you've exceeded the requests per second per user limit that\n * you configured in the Google Developers Console. This limit should be\n * configured to prevent a single or small group of users from exhausting your\n * daily quota, while still allowing reasonable access to all users.\n * @type {String}\n */\n USER_RATE_LIMIT_EXCEEDED: 'USER_RATE_LIMIT_EXCEEDED',\n /**\n * Indicates that you've exceeded your daily limit for Google API(s).\n * @type {String}\n */\n DAILY_LIMIT_EXCEEDED: 'DAILY_LIMIT_EXCEEDED',\n /**\n * Indicates that your Google API key is not valid. Please ensure that you've\n * included the entire key, and that you've either purchased the API or have\n * enabled billing and activated the API to obtain the free quota.\n * @type {String}\n */\n GOOGLE_KEY_INVALID: 'GOOGLE_KEY_INVALID',\n /**\n * Indicates that maximum number of elements limit is exceeded. For\n * example, for the Distance Matrix API; occurs when the product of\n * origins and destinations exceeds the per-query limit.\n * @type {String}\n */\n MAX_ELEMENTS_EXCEEDED: 'MAX_ELEMENTS_EXCEEDED',\n /**\n * Indicates that the request contained more than 25 origins,\n * or more than 25 destinations.\n * @type {String}\n */\n MAX_DIMENSIONS_EXCEEDED: 'MAX_DIMENSIONS_EXCEEDED',\n /**\n * Indicates that the request contained more than allowed waypoints.\n * @type {String}\n */\n MAX_WAYPOINTS_EXCEEDED: 'MAX_WAYPOINTS_EXCEEDED',\n /**\n * Indicates that the request body is not valid JSON.\n * @type {String}\n */\n PARSE_ERROR: 'PARSE_ERROR',\n /**\n * Indicates that the requested resource could not be found.\n * Note that this also covers `ZERO_RESULTS`.\n * @type {String}\n */\n NOT_FOUND: 'NOT_FOUND',\n /**\n * Indicates that an internal error (such as XHR cross-domain, etc) has occured.\n * @type {String}\n */\n INTERNAL_ERROR: 'INTERNAL_ERROR',\n /**\n * Indicates that an unknown error has occured.\n * @type {String}\n */\n UNKNOWN_ERROR: 'UNKNOWN_ERROR'\n};\n\n// ---------------------------\n// HELPER METHODS\n// ---------------------------\n\n/**\n * @private\n */\nfunction errorCodeFromStatus(status) {\n if (!status) return GeoError.Code.INVALID_RESPONSE;\n if (status === 'OK') return null;\n if (status === 'ZERO_RESULTS') return GeoError.Code.NOT_FOUND;\n if (GeoError.Code.hasOwnProperty(status)) return status;\n return null;\n}\n\n/**\n * Gets `GeoError.Code` from the given response error reason.\n * @private\n *\n * @param {String} reason\n * Google response error reason.\n *\n * @returns {String}\n */\nfunction errorCodeFromReason(reason) {\n switch (reason) {\n case 'invalid':\n return GeoError.Code.INVALID_REQUEST;\n case 'dailyLimitExceeded':\n return GeoError.Code.DAILY_LIMIT_EXCEEDED;\n case 'keyInvalid':\n return GeoError.Code.GOOGLE_KEY_INVALID;\n case 'userRateLimitExceeded':\n return GeoError.Code.USER_RATE_LIMIT_EXCEEDED;\n case 'notFound':\n return GeoError.Code.NOT_FOUND;\n case 'parseError':\n return GeoError.Code.PARSE_ERROR;\n default:\n return null;\n }\n}\n\n// ---------------------------\n// EXPORT\n// ---------------------------\n\nexport default GeoError;\n","import utils from '../lib/utils';\nimport fetch from '../lib/fetch';\nimport enums from './enums';\nimport GeoError from './geo.error';\n\n/**\n * Helper methods.\n * @type {Object}\n * @private\n */\nconst geoHelper = {\n\n toGoogleCoords(coords) {\n return {\n lat: coords.lat || coords.latitude,\n lng: coords.lng || coords.longitude\n };\n },\n\n fromGoogleCoords(coords) {\n return {\n latitude: coords.latitude || coords.lat,\n longitude: coords.longitude || coords.lng\n };\n },\n\n // used for distance matrix origins and destinations\n toPointList(arr) {\n arr = utils.isArray(arr) ? arr : [arr];\n return arr.map(o => {\n return utils.isString(o) ? o : geoHelper.toGoogleCoords(o);\n });\n },\n\n getGeocodeComps(comp) {\n return {\n route: comp.route,\n locality: comp.locality,\n administrative_area: comp.administrativeArea, // eslint-disable-line camelcase\n postal_code: comp.postalCode, // eslint-disable-line camelcase\n country: comp.country,\n region: comp.region\n };\n },\n\n // Geocode examples:\n // address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=API_KEY\n // address=Winnetka&bounds=34.172684,-118.604794|34.236144,-118.500938&key=API_KEY\n // address=santa+cruz&components=country:ES&key=API_KEY\n // components=administrative_area:TX|country:US&key=API_KEY\n // Reverse Geocode examples:\n // latlng=40.714224,-73.961452&key=API_KEY\n // place_id=ChIJd8BlQ2BZwokRAFUEcm_qrcA&key=API_KEY\n buildGeocodeParams(options, reverse) {\n let params = [],\n e = utils.encodeURI;\n\n if (reverse) {\n if (options.placeId) {\n params.push(`place_id=${options.placeId}`);\n } else if (options.latitude && options.longitude) {\n params.push(`latlng=${options.latitude},${options.longitude}`);\n }\n } else {\n if (options.address) {\n params.push(`address=${e(options.address)}`);\n }\n\n let geoComps = geoHelper.getGeocodeComps(options);\n geoComps = utils.params(geoComps, { operator: ':', separator: '|' });\n params.push(`components=${geoComps}`);\n\n let b = options.bounds;\n if (utils.isArray(b) && b.length === 4) {\n params.push(`bounds=${b[0]},${b[1]}|${b[2]},${b[3]}`);\n } else if (utils.isPlainObject(b) && Object.keys(b).length === 4) {\n params.push(`bounds=${b.southwestLat},${b.southwestLng}|${b.northeastLat},${b.northeastLng}`);\n }\n }\n\n params.push(`language=${options.language}`);\n params.push(`key=${options.key}`);\n return params.join('&');\n },\n\n // See https://developers.google.com/maps/documentation/geocoding/intro\n formatGeocodeResults(results) {\n if (!utils.isArray(results) || results.length <= 0) {\n return {\n location: null,\n address: null,\n formattedAddress: '',\n type: null, // locationType\n placeId: ''\n };\n }\n\n let i, c,\n o = {},\n data = results[0],\n comps = data.address_components;\n\n for (i = 0; i < comps.length; i += 1) {\n c = comps[i];\n if (c.types && c.types.length > 0) {\n o[c.types[0]] = c.long_name;\n o[c.types[0] + '_s'] = c.short_name;\n }\n }\n\n let geometry = data.geometry;\n return {\n coords: geometry && geometry.location ? {\n latitude: geometry.location.lat,\n longitude: geometry.location.lng\n } : null,\n address: {\n commonName: o.point_of_interest\n || o.premise\n || o.subpremise\n || o.colloquial_area\n || '',\n streetNumber: o.street_number || '',\n street: o.administrative_area_level_4\n || o.administrative_area_level_3\n || o.route\n || '',\n route: o.route || '',\n neighborhood: o.neighborhood\n || o.administrative_area_level_5\n || o.administrative_area_level_4\n || '',\n town: o.sublocality || o.administrative_area_level_2 || '',\n city: o.locality || o.administrative_area_level_1 || '',\n region: o.administrative_area_level_2\n || o.administrative_area_level_1\n || '',\n postalCode: o.postal_code || '',\n state: o.administrative_area_level_1 || '',\n stateCode: o.administrative_area_level_1_s || '',\n country: o.country || '',\n countryCode: o.country_s || ''\n },\n formattedAddress: data.formatted_address,\n type: geometry.location_type || '',\n placeId: data.place_id,\n timestamp: utils.time()\n };\n },\n\n geocode(reverse, conf, options, callback) {\n let opts = {};\n if (utils.isString(options)) {\n opts = {};\n let prop = reverse ? 'placeId' : 'address';\n opts[prop] = options;\n } else if (utils.isPlainObject(options)) {\n opts = options;\n } else {\n throw new GeoError(GeoError.Code.INVALID_PARAMETERS);\n }\n\n if (reverse) {\n let coordsSet = utils.isNumber(options.latitude)\n && utils.isNumber(options.longitude);\n if (!utils.isString(options.placeId) && !coordsSet) {\n throw new GeoError(GeoError.Code.INVALID_PARAMETERS);\n }\n }\n\n opts = utils.extend({\n key: conf.google.key || '',\n language: conf.language || 'en',\n raw: false\n }, opts);\n\n let query = geoHelper.buildGeocodeParams(opts, reverse),\n url = utils.setProtocol(enums.URL.GOOGLE_GEOCODE, conf.https),\n xhrOpts = {\n url: `${url}?${query}`\n };\n\n fetch.xhr(xhrOpts, (err, xhr) => {\n if (err) return callback(GeoError.create(err), null);\n\n let response = utils.safeJsonParse(xhr.responseText),\n gErr = GeoError.fromResponse(response);\n\n if (gErr) return callback(gErr, null);\n\n response = options.raw\n ? response\n : geoHelper.formatGeocodeResults(response.results);\n callback(null, response);\n });\n },\n\n // See https://developers.google.com/maps/documentation/distance-matrix/intro\n // Raw Result Example:\n // {\n // \"destination_addresses\" : [ \"San Francisco, CA, USA\", \"Victoria, BC, Canada\" ],\n // \"origin_addresses\" : [ \"Vancouver, BC, Canada\", \"Seattle, WA, USA\" ],\n // \"rows\" : [\n // {\n // \"elements\" : [\n // {\n // \"distance\" : { \"text\" : \"1,704 km\", \"value\" : 1704324 },\n // \"duration\" : { \"text\" : \"3 days 19 hours\", \"value\" : 327061\n // },\n // \"status\" : \"OK\"\n // },\n // {\n // \"distance\" : { \"text\" : \"138 km\", \"value\" : 138295 },\n // \"duration\" : { \"text\" : \"6 hours 44 mins\", \"value\" : 24236 },\n // \"status\" : \"OK\"\n // }\n // ]\n // },\n // {\n // \"elements\" : [\n // {\n // \"distance\" : { \"text\" : \"1,452 km\", \"value\" : 1451623 },\n // \"duration\" : { \"text\" : \"3 days 4 hours\", \"value\" : 275062 },\n // \"status\" : \"OK\"\n // },\n // {\n // \"distance\" : { \"text\" : \"146 km\", \"value\" : 146496 },\n // \"duration\" : { \"text\" : \"2 hours 52 mins\", \"value\" : 10324 },\n // \"status\" : \"OK\"\n // }\n // ]\n // }\n // ],\n // \"status\" : \"OK\"\n // }\n // Formatted to:\n\n formatDistanceResults(results) {\n if (!utils.isPlainObject(results)) {\n return null;\n }\n\n let arr = [],\n origins = results.originAddresses,\n dests = results.destinationAddresses,\n rows = results.rows;\n\n // [\n // {\n // from: 'Vancouver, BC, Canada',\n // to: 'San Francisco, CA, USA',\n // distance: { value: 1704107, text: \"1,704 km\" },\n // duration: { value: 327025, text: \"3 days 19 hours\" },\n // fare: { currency: \"USD\", value: 6, text: \"$6.00\" }\n // },\n // ...\n // ]\n\n let e;\n origins.forEach((origin, oIndex) => {\n dests.forEach((dest, dIndex) => {\n e = rows[oIndex].elements[dIndex];\n arr.push({\n from: origin,\n to: dest,\n distance: e.distance,\n duration: e.duration,\n fare: e.fare,\n timestamp: utils.time()\n });\n });\n });\n\n return arr;\n },\n\n // Converts a map-styles object in to static map styles (formatted query-string params).\n // See https://developers.google.com/maps/documentation/static-maps/styling\n mapStylesToParams(styles) {\n if (!styles) return '';\n if (!utils.isArray(styles)) styles = [styles];\n let result = [];\n styles.forEach((v, i, a) => {\n let style = '';\n if (v.stylers) { // only if there is a styler object\n if (v.stylers.length > 0) { // Needs to have a style rule to be valid.\n style += (v.hasOwnProperty('featureType') ? 'feature:' + v.featureType : 'feature:all') + '|';\n style += (v.hasOwnProperty('elementType') ? 'element:' + v.elementType : 'element:all') + '|';\n v.stylers.forEach((val, i, a) => {\n let propName = Object.keys(val)[0],\n propVal = val[propName].toString().replace('#', '0x');\n style += propName + ':' + propVal + '|';\n });\n }\n }\n result.push('style=' + encodeURIComponent(style));\n });\n return result.join('&');\n }\n\n};\n\nexport default geoHelper;\n","import utils from '../lib/utils';\n\nclass GeoWatcher {\n\n constructor(onChange, onError, options = {}) {\n this.isCleared = false;\n this.cycle = 0;\n this._timer = null;\n this.id = navigator.geolocation.watchPosition(\n pos => {\n this.cycle++;\n if (utils.isFunction(onChange)) onChange(pos);\n },\n err => {\n this.cycle++;\n if (utils.isFunction(onError)) onError(err);\n if (options.clearOnError) {\n this.clear();\n }\n },\n options\n );\n }\n\n _clear() {\n navigator.geolocation.clearWatch(this.id);\n this.isCleared = true;\n this._timer = null;\n }\n\n clear(delay, callback) {\n let d = utils.isNumber(delay) ? delay : 0,\n cb = utils.isFunction(callback) ? callback\n : utils.isFunction(delay) ? delay : null;\n // clear any previous timeout\n if (this._timer) {\n clearTimeout(this._timer);\n this._timer = null;\n }\n // check if watcher is not cleared\n if (!this.isCleared) {\n if (d === 0) {\n this._clear();\n if (cb) cb();\n return;\n }\n this._timer = setTimeout(() => {\n this._clear();\n if (cb) cb();\n }, d);\n }\n }\n\n}\n\n// ---------------------------\n// EXPORT\n// ---------------------------\n\nexport default GeoWatcher;\n","import utils from '../lib/utils';\nimport fetch from '../lib/fetch';\nimport geoHelper from './geo.helper';\nimport GeoError from './geo.error';\nimport GeoWatcher from './geo.watcher';\nimport enums from './enums';\n\n/**\n * Radius of earth in kilometers.\n * @private\n * @type {Number}\n */\nconst EARTH_RADIUS_KM = 6371;\n\n/**\n * Radius of earth in miles.\n * @private\n * @type {Number}\n */\nconst EARTH_RADIUS_MI = 3959;\n\n/**\n * Storage for Geolocator default configuration.\n *\n * @readonly\n * @private\n */\nconst defaultConfig = {\n language: 'en',\n https: true,\n google: {\n version: '3', // latest 3.x\n key: '',\n styles: null\n }\n};\n\n/**\n * Geolocator library that provides methods for getting geo-location information,\n * geocoding, address look-ups, distance & durations, timezone information and more...\n * This library makes use of HTML5 position feautures, implements Google APIs\n * and other services.\n *\n * Important Notes:\n *\n * Although some calls might work without a key, it is generally required by\n * most {@link https://developers.google.com/maps/faq#using-google-maps-apis|Goolge APIs}\n * (such as Time Zone API). To get a free (or premium) key,\n * {@link https://developers.google.com/maps/documentation/javascript/|click here}.\n * After getting a key, you can enable multiple APIs for it. Make sure you\n * {@link https://console.developers.google.com|enable}\n * all the APIs supported by Geolocator.\n *\n * Note that browser API keys cannot have referer restrictions when used\n * with some Google APIs.\n *\n * Make sure your doctype is HTML5 and you're calling Geolocation APIs from an\n * HTTPS page. Geolocation API is removed from unsecured origins in Chrome 50.\n * Other browsers are expected to follow.\n *\n * @license MIT\n * @copyright 2019, Onur Yıldırım \n */\nclass geolocator {\n\n // ---------------------------\n // PROPERTIES\n // ---------------------------\n\n /**\n * Geolocator Error class that provides a common type of error object for\n * the various APIs implemented in Geolocator. All callbacks of Geolocator\n * will include an instance of this object as the first argument; if the\n * corresponding operation fails. Also all thrown errors will be an instance\n * of this object.\n *\n * This object also enumerates\n * {@link ?api=geolocator-error#GeoError.Code|Geolocator Error codes}.\n *\n * @see {@link ?api=geolocator-error|`GeoError` documentation}\n * @type {GeoError}\n * @readonly\n */\n static get Error() {\n return GeoError;\n }\n\n /**\n * Documented separately in enums.js\n * @private\n */\n static get MapTypeId() {\n return enums.MapTypeId;\n }\n\n /**\n * Documented separately in enums.js\n * @private\n */\n static get LocationType() {\n return enums.LocationType;\n }\n\n /**\n * Documented separately in enums.js\n * @private\n */\n static get TravelMode() {\n return enums.TravelMode;\n }\n\n /**\n * Documented separately in enums.js\n * @private\n */\n static get UnitSystem() {\n return enums.UnitSystem;\n }\n\n /**\n * Documented separately in enums.js\n * @private\n */\n static get RadioType() {\n return enums.RadioType;\n }\n\n /**\n * Documented separately in enums.js\n * @private\n */\n static get DistanceFormula() {\n return enums.DistanceFormula;\n }\n\n /**\n * Documented separately in enums.js\n * @private\n */\n static get ImageFormat() {\n return enums.ImageFormat;\n }\n\n // ---------------------------\n // STATIC METHODS\n // ---------------------------\n\n /**\n * Sets or gets the geolocator configuration object.\n * Make sure you configure Geolocator before calling other methods that\n * require a Google API key.\n *\n * @param {Object} [options]\n * Configuration object. If omitted, this method returns the current\n * configuration.\n * @param {String} [options.language=\"en\"]\n * Language to be used for API requests that supports language\n * configurations. This is generally used for Google APIs.\n * See {@link https://developers.google.com/maps/faq#languagesupport|supported languages}.\n * @param {Boolean} [options.https=true]\n * As Google recommends; using HTTPS encryption makes your site\n * more secure, and more resistant to snooping or tampering.\n * If set to `true`, the API calls are made over HTTPS, at all\n * times. Setting to `false` will switch to HTTP (even if the\n * page is on HTTPS). And if set to `null`, current protocol will\n * be used. Note that some APIs might not work with HTTP such as\n * Google Maps TimeZone API.\n * @param {Object} [options.google]\n * Google specific options.\n * @param {String} [options.google.version=\"3\"]\n * Google Maps API version to be used (with\n * `geolocator.createMap()`) method. The default version\n * value is tested and works with Geolocator. You can set a\n * greater value or the latest version number and it should\n * work; but it's not guaranteed. Find out the\n * {@link https://developers.google.com/maps/documentation/javascript/versions|latest version here}.\n * @param {String} [options.google.key=\"\"]\n * API key to be used with Google API calls. Although some\n * calls might work without a key, it is generally required\n * by most Goolge APIs. To get a free (or premium) key,\n * {@link https://developers.google.com/maps/documentation/javascript/|click here}.\n * @param {Array} [options.google.styles]\n * An array of objects to customize the presentation of the\n * Google base maps, changing the visual display of such\n * elements as roads, parks, and built-up areas.\n * See {@link https://developers.google.com/maps/documentation/javascript/styling|Styling Maps}.\n *\n * @returns {Object} - Returns the current or updated configuration object.\n *\n * @example\n * geolocator.config({\n * language: \"en\",\n * google: {\n * version: \"3\",\n * key: \"YOUR-GOOGLE-API-KEY\"\n * }\n * });\n */\n static config(options) {\n if (options) {\n geolocator._.config = utils.extend(defaultConfig, options);\n }\n return geolocator._.config;\n }\n\n /**\n * Gets a static map image URL which can be embeded via an `` tag\n * on the page.\n *\n * Note that, if `options.center` is set to an address (instead of\n * coordinates) and `options.marker` is also set; we will need to geocode\n * that address to get center coordinates for the marker.\n * In this case, you must use the `callback` parameter to get the async\n * result. Otherwise, this method will directly return a `String`.\n *\n * Make sure you have enabled Static Maps API (and Geocoding API if\n * `marker` is enabled) in your Google Developers console.\n *\n * For interactive map, see {@link #geolocator.createMap|`geolocator.createMap()` method}.\n *\n * @see {@link https://developers.google.com/maps/documentation/static-maps/intro|Static Maps}\n * @see {@link https://developers.google.com/maps/documentation/static-maps/usage-limits|Usage Limits}\n *\n * @param {Object} options\n * Static map options.\n * @param {String|Object} options.center\n * Defines the center of the map and the location.\n * Either an address `String` or an coordinates `Object` with\n * `latitude:Number` and `longitude:Number` properties.\n * @param {String} [options.mapTypeId=\"roadmap\"]\n * Type of the map to be created.\n * See {@link #geolocator.MapTypeId|`geolocator.MapTypeId` enumeration}\n * for possible values.\n * @param {String|Object} [options.size=\"600x300\"]\n * Defines the size (in pixels) of the returned image.\n * Either a string in `widthxheight` format or an Object\n * with `width:Number` and `height:Number` properties.\n * @param {Number} [options.scale=1]\n * Affects the number of pixels that are returned. scale=2\n * returns twice as many pixels as scale=1 while retaining\n * the same coverage area and level of detail (i.e. the\n * contents of the map don't change). Accepted values are 1,\n * 2 and 4 (4 is only available to Google Maps APIs Premium\n * Plan customers.)\n * @param {Number} [options.zoom=9]\n * Zoom level to be set for the map.\n * @param {String} [options.format=png]\n * Defines the format of the resulting image.\n * See {@link #geolocator.ImageFormat|`geolocator.ImageFormat` enumeration}\n * for possible values.\n * @param {Boolean|String} [options.marker=true]\n * Specifies whether to add a marker to the center of the map.\n * You can define the color of the marker by passing a color\n * `String` instead of a `Boolean`. Color can be a predefined\n * color from the set `red` (default), `black`, `brown`,\n * `green`, `purple`, `yellow`, `blue`, `gray`, `orange` and\n * `white`; or a HEX 24-bit color (e.g. `\"0xFF0000\"`).\n * Note that marker will not be visible if `center` is set to\n * a `String` address and you don't use the callback.\n * @param {String} [options.region]\n * Defines the appropriate borders to display, based on\n * geo-political sensitivities. Accepts a region code\n * specified as a two-character ccTLD (top-level domain)\n * value. e.g. `\"us\"`.\n * @param {Array} [options.styles]\n * An array of objects to customize the presentation of the\n * Google base maps, changing the visual display of such\n * elements as roads, parks, and built-up areas.\n * This will default to the global styles set via\n * {@link #geolocator.config|`geolocator.config()` method}, if any.\n * See {@link https://developers.google.com/maps/documentation/javascript/styling|Styling Maps}.\n *\n * @param {Function} [callback]\n * Callback function to be executed when the static map URL is built.\n * This takes 2 arguments: `function (err, url) { ... }`.\n * If omitted, this method will directly return the static map\n * image URL; but (if enabled) the marker will not be visible if\n * `options.center` is set to an address `String` instead of a\n * coordinates `Object`.\n *\n * @returns {String|void}\n * If a callback is passed, this will return `void`.\n * Otherwise, a `String` that represents the URL of the static map.\n *\n * @example\n * // Async example (with address and marker)\n * var options = {\n * center: \"Los Angles, CA, US\",\n * mapTypeId: geolocator.MapTypeId.ROADMAP,\n * size: \"600x300\",\n * scale: 1,\n * zoom: 5,\n * marker: \"0xFFCC00\",\n * format: geolocator.ImageFormat.PNG\n * };\n * geolocator.getStaticMap(options, function (err, url) {\n * if (!err) {\n * document.getElementById('my-img').src = url;\n * }\n * });\n *\n * @example\n * // Sync example (with coordinates)\n * var options = {\n * center: {\n * longitude: 34.0522342,\n * latitude: -118.2436849\n * },\n * mapTypeId: geolocator.MapTypeId.ROADMAP,\n * size: \"600x300\",\n * scale: 1,\n * zoom: 5,\n * marker: \"0xFFCC00\",\n * format: geolocator.ImageFormat.PNG\n * };\n * document.getElementById('my-img').src = geolocator.getStaticMap(options);\n */\n static getStaticMap(options, callback) {\n if (!utils.isPlainObject(options) || !options.center) {\n throw new GeoError(GeoError.Code.INVALID_PARAMETERS,\n 'A center address or coordinates are required.');\n }\n\n if (utils.isString(options.center)) {\n return geolocator.geocode(options.center, (err, location) => {\n if (err) callback(err);\n options.center = location.coords;\n callback(null, geolocator.getStaticMap(options));\n });\n }\n\n let conf = geolocator._.config;\n let opts = utils.extend({\n mapTypeId: enums.MapTypeId.ROADMAP,\n size: {\n width: 600,\n height: 300\n },\n scale: 1, // 1 | 2 | (4 for business customers of google maps)\n zoom: 9,\n marker: 'red',\n format: enums.ImageFormat.PNG,\n language: conf.language || 'en',\n region: null\n }, options);\n\n let center = utils.isPlainObject(opts.center)\n ? `${opts.center.latitude},${opts.center.longitude}`\n : String(opts.center);\n\n let size = utils.isPlainObject(opts.size)\n ? `${opts.size.width}x${opts.size.height}`\n : String(opts.size);\n\n let url = enums.URL.GOOGLE_SATATIC_MAP // not using utils.setProtocol() here\n + `?center=${center}&maptype=${opts.mapTypeId}`\n + `&size=${size}&scale=${opts.scale}&zoom=${opts.zoom}`\n + `&format=${opts.format}&language=${opts.language}`;\n\n if (opts.marker) {\n let color = utils.isString(opts.marker) ? opts.marker : 'red';\n url += '&markers=' + encodeURIComponent(`color:${color}|${center}`);\n }\n if (opts.region) url += '®ion=' + opts.region;\n if (conf.google.key) url += '&key=' + conf.google.key;\n\n let styles = getStyles(opts);\n if (styles) url += '&' + geoHelper.mapStylesToParams(styles);\n\n if (utils.isFunction(callback)) return callback(null, url);\n return url;\n }\n\n /**\n * Creates an interactive Google Map within the given element.\n * Make sure you have enabled Google Static Maps API in your Google Developers console.\n * For static map, see {@link #geolocator.getStaticMap|`geolocator.getStaticMap()` method}.\n * @see {@link https://developers.google.com/maps/documentation/javascript/reference|Google Maps JavaScript API}\n * @see {@link https://developers.google.com/maps/documentation/javascript/usage|Usage Limits}\n *\n * @param {Object|String|HTMLElement|Map} options\n * Either map options object with the following properties or; the ID\n * of a DOM element, or element itself which the map will be\n * created within; or a previously created `google.maps.Map` instance.\n * If a map instance is set, this only will apply the options without\n * re-creating it.\n * @param {String|HTMLElement|Map} options.element\n * Either the ID of a DOM element or the element itself;\n * which the map will be created within; or a previously created\n * `google.maps.Map` instance. If a map instance is set, this\n * only will apply the options without re-creating it.\n * @param {Object} options.center\n * Center coordinates for the map to be created.\n * @param {Number} options.center.latitude\n * Latitude of the center point coordinates.\n * @param {Number} options.center.longitude\n * Longitude of the center point coordinates.\n * @param {String} [options.mapTypeId=\"roadmap\"]\n * Type of the map to be created.\n * See {@link #geolocator.MapTypeId|`geolocator.MapTypeId` enumeration}\n * for possible values.\n * @param {String} [options.title]\n * Title text to be displayed within an `InfoWindow`, when the\n * marker is clicked. This only take effect if `marker` is\n * enabled.\n * @param {Boolean} [options.marker=true]\n * Whether to place a marker at the given coordinates.\n * If `title` is set, an `InfoWindow` will be opened when the\n * marker is clicked.\n * @param {Number} [options.zoom=9]\n * Zoom level to be set for the map.\n * @param {Array} [options.styles]\n * An array of objects to customize the presentation of the\n * Google base maps, changing the visual display of such\n * elements as roads, parks, and built-up areas.\n * This will default to the global styles set via\n * {@link #geolocator.config|`geolocator.config` method}`, if any.\n * See {@link https://developers.google.com/maps/documentation/javascript/styling|Styling Maps}.\n *\n * @param {Function} callback\n * Callback function to be executed when the map is created.\n * This takes 2 arguments: `function (err, map) { ... }`.\n * See {@link #geolocator~MapData|`geolocator~MapData` type} for details.\n *\n * @returns {void}\n *\n * @example\n * var options = {\n * element: \"my-map\",\n * center: {\n * latitude: 48.8534100,\n * longitude: 2.3488000\n * \t},\n * \tmarker: true,\n * \ttitle: \"Paris, France\",\n * \tzoom: 12\n * };\n * geolocator.createMap(options, function (err, map) {\n * if (map && map.infoWindow) {\n * map.infoWindow.open(map.instance, map.marker);\n * }\n * });\n */\n static createMap(options, callback) {\n // if options is not a plain object, consider element ID, `HTMLElement`,\n // `jQuery` instance or `google.maps.Map` instance.\n if (!utils.isPlainObject(options)) {\n options = { element: options };\n }\n\n options = utils.extend({\n element: null,\n mapTypeId: enums.MapTypeId.ROADMAP,\n title: undefined,\n marker: true,\n zoom: 9\n }, options);\n\n let e = options.element,\n elem;\n if (utils.isString(e)) {\n elem = document.getElementById(e);\n } else if (utils.isJQueryObject(e)) {\n elem = e[0];\n } else if (geolocator.isGoogleLoaded() && e instanceof google.maps.Map) {\n elem = e.getDiv();\n }\n\n if (!utils.isElement(elem) && !utils.isNode(elem)) {\n throw new GeoError(GeoError.Code.INVALID_PARAMETERS,\n 'A valid DOM element or element ID is required to create a map.');\n }\n\n if (!utils.isPlainObject(options.center)\n || !utils.isNumber(options.center.latitude)\n || !utils.isNumber(options.center.longitude)) {\n throw new GeoError(GeoError.Code.INVALID_PARAMETERS,\n 'Center coordinates are required to create a map.');\n }\n\n options.element = elem;\n\n let conf = geolocator._.config,\n key = conf.google.key;\n options.styles = getStyles(options);\n\n geolocator.ensureGoogleLoaded(key, err => {\n if (err) {\n throw new GeoError(GeoError.Code.GOOGLE_API_FAILED, String(err.message || err));\n }\n\n let mapData = configCreateMap(options);\n callback(null, mapData);\n });\n }\n\n /**\n * Locates the user's location via HTML5 geolocation. This may\n * require/prompt for user's permission. If the permission is granted we'll\n * get the most accurate location information. Otherwise, we'll fallback to\n * locating via user's IP (if enabled).\n *\n * For better accuracy, Geolocator implements a different approach than the\n * `getCurrentPosition` API; which generally triggers before the device's\n * GPS hardware can provide anything accurate. Thanks to\n * {@link https://github.com/gwilson/getAccurateCurrentPosition#background|Greg Wilson}\n * for the idea.\n *\n * Also note that HTML5 Geolocation feature no more allows insecure origins.\n * See {@link https://goo.gl/rStTGz|this} for more details.\n * This means if you don't call this method from an HTTPS page, it will\n * fail. And if `options.fallbackToIP` is enabled, this will locate by IP.\n *\n * @param {Object} [options]\n * HTML5 geo-location settings with some additional options.\n * @param {Boolean} [options.enableHighAccuracy=true]\n * Specifies whether the device should provide the most accurate\n * position it can. Note that setting this to `true` might\n * consume more CPU and/or battery power; and result in slower\n * response times.\n * @param {Number} [options.desiredAccuracy=30]\n * Minimum accuracy desired, in meters. Position will not be\n * returned until this is met, before the timeout. This only\n * takes effect if `enableHighAccuracy` is set to `true`.\n * @param {Number} [options.timeout=5000]\n * HTML5 position timeout setting in milliseconds. Setting this\n * to `Infinity` means that Geolocator won't return until the\n * position is available.\n * @param {Number} [options.maximumWait=10000]\n * Maximum time to wait (in milliseconds) for the desired\n * accuracy (which should be greater than `timeout`).\n * This only takes effect if `enableHighAccuracy` is set to\n * `true`.\n * @param {Number} [options.maximumAge=0]\n * HTML5 position maximum age. Indicates the maximum age in\n * milliseconds of a possible cached position that is acceptable\n * to return. `0` means, the device cannot use a cached position\n * and must attempt to retrieve the real current position. If set\n * to `Infinity` the device must return a cached position\n * regardless of its age. Note that if `enableHighAccuracy` is\n * set to `true`, `maximumAge` will be forced to `0`.\n * @param {Function} [options.onProgress]\n * If `enableHighAccuracy` is set to `true`, you can use this\n * callback to check the progress of the location accuracy;\n * while waiting for the final, best accurate location.\n * @param {Boolean} [options.fallbackToIP=false]\n * Specifies whether to fallback to IP geolocation if the HTML5\n * geolocation fails (e.g. user rejection).\n * @param {Boolean} [options.addressLookup=false]\n * Specifies whether to run a reverse-geocode operation for the\n * fetched coordinates to retrieve detailed address information.\n * Note that this means an additional request which requires a\n * Google API key to be set in the Geolocator configuration.\n * See {@link #geolocator.config|`geolocator.config()`}.\n * @param {Boolean} [options.timezone=false]\n * Specifies whether to also fetch the time zone information for\n * the receieved coordinates. Note that this means an additional\n * request which requires a Google API key to be set in the\n * Geolocator configuration.\n * See {@link #geolocator.config|`geolocator.config()`}.\n * @param {String|MapOptions} [options.map]\n * In order to create an interactive map from the fetched\n * location coordinates; either set this to a\n * {@link #geolocator~MapOptions|`MapOptions` object}\n * or; the ID of a DOM element or DOM element itself which the\n * map will be created within.\n * @param {Boolean|Object} [options.staticMap=false]\n * Set to `true` to get a static Google Map image URL (with\n * default options); or pass a static map options object.\n *\n * @param {Function} callback\n * Callback function to be executed when the request completes.\n * This takes 2 arguments: `function (err, location) { ... }`.\n * See {@link #geolocator~Location|`geolocator~Location` type} for details.\n *\n * @returns {void}\n *\n * @example\n * var options = {\n * enableHighAccuracy: true,\n * desiredAccuracy: 30,\n * timeout: 5000,\n * maximumWait: 10000,\n * maximumAge: 0,\n * fallbackToIP: true,\n * addressLookup: true,\n * timezone: true,\n * map: \"my-map\",\n * staticMap: true\n * };\n * geolocator.locate(options, function (err, location) {\n * console.log(err || location);\n * });\n *\n * @example\n * // location result:\n * {\n * coords: {\n * latitude: 37.4224764,\n * longitude: -122.0842499,\n * accuracy: 30,\n * altitude: null,\n * altitudeAccuracy: null,\n * heading: null,\n * speed: null\n * },\n * address: {\n * commonName: \"\",\n * street: \"Amphitheatre Pkwy\",\n * route: \"Amphitheatre Pkwy\",\n * streetNumber: \"1600\",\n * neighborhood: \"\",\n * town: \"\",\n * city: \"Mountain View\",\n * region: \"Santa Clara County\",\n * state: \"California\",\n * stateCode: \"CA\",\n * postalCode: \"94043\",\n * country: \"United States\",\n * countryCode: \"US\"\n * },\n * formattedAddress: \"1600 Amphitheatre Parkway, Mountain View, CA 94043, USA\",\n * type: \"ROOFTOP\",\n * placeId: \"ChIJ2eUgeAK6j4ARbn5u_wAGqWA\",\n * timezone: {\n * id: \"America/Los_Angeles\",\n * name: \"Pacific Standard Time\",\n * abbr: \"PST\",\n * dstOffset: 0,\n * rawOffset: -28800\n * },\n * flag: \"//cdnjs.cloudflare.com/ajax/libs/flag-icon-css/2.3.1/flags/4x3/us.svg\",\n * map: {\n * element: HTMLElement,\n * instance: Object, // google.maps.Map\n * marker: Object, // google.maps.Marker\n * infoWindow: Object, // google.maps.InfoWindow\n * options: Object // map options\n * },\n * staticMap: \"//maps.googleapis.com/maps/api/staticmap?center=37.4224764,-122.0842499&maptype=roadmap&size=600x300&scale=1&zoom=9&format=png&language=en&markers=color%3Ared%7C37.4224764%2C2-122.0842499&key=YOUR-GOOGLE-API-KEY\",\n * timestamp: 1456795956380\n * }\n */\n static locate(options, callback) {\n options = utils.extend({\n enableHighAccuracy: true,\n timeout: 6000,\n maximumWait: 10000,\n maximumAge: 0,\n desiredAccuracy: 30,\n onProgress: utils.noop,\n fallbackToIP: false,\n addressLookup: false,\n timezone: false,\n map: undefined,\n staticMap: false\n }, options);\n\n // force disable cache if high-accuracy is enabled\n if (options.enableHighAccuracy) options.maximumAge = 0;\n // set a min value for timeout\n if (options.timeout < 1000) options.timeout = 1000;\n // max wait should not be less than timeout\n if (options.maximumWait < options.timeout) options.maximumWait = options.timeout;\n\n // check options and Google key\n checkGoogleKey(options);\n\n let cb = callbackMap(options, callback);\n\n function fallbackToIP(error) {\n if (options.fallbackToIP) {\n return geolocator.locateByIP(options, (err, location) => {\n if (err) return cb(err, null);\n return cb(null, location);\n });\n }\n cb(error, null);\n }\n function onPositionReceived(location) {\n fetchAddressAndTimezone(location, options, cb);\n }\n function onPositionError(err) {\n err = GeoError.create(err);\n fallbackToIP(err);\n }\n\n if (geolocator.isGeolocationSupported()) {\n if (options.enableHighAccuracy) {\n locateAccurate(options, onPositionReceived, onPositionError);\n } else {\n navigator.geolocation.getCurrentPosition(onPositionReceived, onPositionError, options);\n }\n } else {\n let err = new GeoError(GeoError.Code.GEOLOCATION_NOT_SUPPORTED);\n fallbackToIP(err);\n }\n }\n\n /**\n * Returns a location and accuracy radius based on information about cell\n * towers and WiFi nodes that the mobile client can detect; via the Google\n * Maps Geolocation API.\n * @see {@link https://developers.google.com/maps/documentation/geolocation/intro|Google Maps Geolocation API}\n * @see {@link https://developers.google.com/maps/documentation/geolocation/usage-limits|Usage Limits}\n *\n * @param {Object} [options]\n * Geolocation options.\n * @param {Number} [options.homeMobileCountryCode]\n * The mobile country code (MCC) for the device's home network.\n * @param {Number} [options.homeMobileNetworkCode]\n * The mobile network code (MNC) for the device's home network.\n * @param {String} [options.radioType]\n * The mobile radio type.\n * See {@link #geolocator.RadioType|`geolocator.RadioType` enumeration}\n * for possible values. While this field is optional, it should\n * be included if a value is available, for more accurate results.\n * @param {string} [options.carrier]\n * The carrier name. e.g. \"Vodafone\"\n * @param {Boolean} [options.fallbackToIP=false]\n * Specifies whether to fallback to IP geolocation if wifi and\n * cell tower signals are not available. Note that the IP address\n * in the request header may not be the IP of the device. Set\n * `fallbackToIP` to `false` to disable fall back.\n * @param {Array} [options.cellTowers]\n * An array of cell tower objects.\n * See {@link https://developers.google.com/maps/documentation/geolocation/intro#cell_tower_object|Cell tower objects} for details.\n * @param {Array} [options.wifiAccessPoints]\n * An array of WiFi access point objects.\n * See {@link https://developers.google.com/maps/documentation/geolocation/intro#wifi_access_point_object|WiFi access point objects} for details.\n * @param {Boolean} [options.addressLookup=false]\n * Specifies whether to run a reverse-geocode operation for the\n * fetched coordinates to retrieve detailed address information.\n * Note that this means an additional request which requires a\n * Google API key to be set in the Geolocator configuration.\n * See {@link #geolocator.config|`geolocator.config()`}.\n * @param {Boolean} [options.timezone=false]\n * Specifies whether to also fetch the time zone information for\n * the receieved coordinates. Note that this means an additional\n * request which requires a Google API key to be set in the\n * Geolocator configuration.\n * See {@link #geolocator.config|`geolocator.config()`}.\n * @param {String|MapOptions} [options.map]\n * In order to create an interactive map from the fetched\n * location coordinates; either set this to a\n * {@link #geolocator~MapOptions|`MapOptions` object}\n * or; the ID of a DOM element or DOM element itself which the\n * map will be created within.\n * @param {Boolean|Object} [options.staticMap=false]\n * Set to `true` to get a static Google Map image URL (with\n * default options); or pass a static map options object.\n * @param {Boolean} [options.raw=false]\n * \t Whether to return the raw Google API result.\n * @param {Function} callback\n * Callback function to be executed when the request completes.\n * This takes 2 arguments: `function (err, location) { ... }`.\n * See {@link #geolocator~Location|`geolocator~Location` type} for details.\n *\n * @returns {void}\n *\n * @example\n * var options = {\n * homeMobileCountryCode: 310,\n * homeMobileNetworkCode: 410,\n * carrier: 'Vodafone',\n * radioType: geolocator.RadioType.GSM,\n * fallbackToIP: true,\n * addressLookup: false,\n * timezone: false,\n * map: \"my-map\",\n * staticMap: false\n * };\n * geolocator.locateByMobile(options, function (err, location) {\n * console.log(err || location);\n * });\n */\n static locateByMobile(options, callback) {\n if (!utils.isPlainObject(options)) {\n throw new GeoError(GeoError.Code.INVALID_PARAMETERS);\n }\n\n let cb = callbackMap(options, callback);\n\n options = utils.extend({\n homeMobileCountryCode: undefined,\n homeMobileNetworkCode: undefined,\n radioType: undefined,\n carrier: undefined,\n fallbackToIP: false,\n cellTowers: undefined,\n wifiAccessPoints: undefined,\n addressLookup: false,\n timezone: false,\n map: undefined,\n raw: false\n }, options);\n\n options.considerIp = options.fallbackToIP;\n // check Google key\n checkGoogleKey();\n\n let conf = geolocator._.config,\n key = conf.google.key || '',\n url = utils.setProtocol(enums.URL.GOOGLE_GEOLOCATION, conf.https),\n xhrOpts = {\n url: `${url}?key=${key}`,\n headers: {\n 'Content-Type': 'application/json'\n },\n data: JSON.stringify(options)\n };\n // console.log(xhrOpts.data);\n\n fetch.post(xhrOpts, (err, xhr) => {\n let response = getXHRResponse(err, xhr);\n if (GeoError.isGeoError(response)) return cb(response, null);\n\n response = options.raw ? response : {\n coords: {\n latitude: response.location.lat,\n longitude: response.location.lng,\n accuracy: response.accuracy\n },\n timestamp: utils.time()\n };\n\n fetchAddressAndTimezone(response, options, cb);\n\n // e.g. raw response\n // {\n // \"location\": {\n // \"lat\": 51.0,\n // \"lng\": -0.1\n // },\n // \"accuracy\": 1200.4\n // }\n });\n }\n\n /**\n * Locates the user's location by the client's IP.\n *\n * This method uses a free lookup service, by default.\n * In order to change the source provider, you can use\n * {@link #geolocator.setGeoIPSource|`geolocator.setGeoIPSource()` method}.\n *\n * @param {Object} [options]\n * Locate options.\n * @param {Boolean} [options.addressLookup=false]\n * Specifies whether to run a reverse-geocode operation for the\n * fetched coordinates to retrieve detailed address information.\n * Since no precise address can be fetched from an IP addres; you\n * should only enable this if the Geo-IP Source returns no useful\n * address information other than coordinates. Also, note that\n * this means an additional request which requires a Google API\n * key to be set in the Geolocator configuration.\n * See {@link #geolocator.config|`geolocator.config()`}.\n * @param {Boolean} [options.timezone=false]\n * Specifies whether to also fetch the time zone information for\n * the receieved coordinates. Note that this means an additional\n * request which requires a Google API key to be set in the\n * Geolocator configuration.\n * See {@link #geolocator.config|`geolocator.config()`}.\n * @param {String|MapOptions} [options.map]\n * In order to create an interactive map from the fetched\n * location coordinates; either set this to a\n * {@link #geolocator~MapOptions|`MapOptions` object}\n * or; the ID of a DOM element or DOM element itself which the\n * map will be created within.\n * @param {Boolean|Object} [options.staticMap=false]\n * Set to `true` to get a static Google Map image URL (with\n * default options); or pass a static map options object.\n * @param {Function} callback\n * Callback function to be executed when the request completes.\n * This takes 2 arguments: `function (err, location) { ... }`.\n * See {@link #geolocator~Location|`geolocator~Location` type} for details.\n *\n * @returns {void}\n *\n * @example\n * var options = {\n * \taddressLookup: true,\n * \ttimezone: true,\n * \tmap: \"my-map\",\n * \tstaticMap: true\n * };\n * geolocator.locateByIP(options, function (err, location) {\n * \tconsole.log(err || location);\n * });\n *\n * @example\n * // location result:\n * {\n * coords: {\n * latitude: 41.0214,\n * longitude: 28.9948,\n * },\n * address: {\n * city: \"Istanbul\",\n * region: \"34\",\n * state: \"34\",\n * country: \"Turkey\",\n * countryCode: \"TR\"\n * },\n * formattedAddress: \"Demirtaş, Tesviyeci Sk. No:7, 34134 Fatih/İstanbul, Turkey\",\n * type: \"ROOFTOP\",\n * placeId: \"ChIJ-ZRLfO25yhQRBi5YJxX80Q0\",\n * timezone: {\n * id: \"Europe/Istanbul\",\n * name: \"Eastern European Summer Time\",\n * abbr: \"EEST\",\n * dstOffset: 3600,\n * rawOffset: 7200\n * },\n * flag: \"//cdnjs.cloudflare.com/ajax/libs/flag-icon-css/2.3.1/flags/4x3/tr.svg\",\n * map: {\n * element: HTMLElement,\n * instance: Object, // google.maps.Map\n * marker: Object, // google.maps.Marker\n * infoWindow: Object, // google.maps.InfoWindow\n * options: Object // map options\n * },\n * staticMap: \"//maps.googleapis.com/maps/api/staticmap?center=41.0214,28.9948&maptype=roadmap&size=600x300&scale=1&zoom=9&format=png&language=en&markers=color%3Ared%7C41.0214%2C228.9948&key=YOUR-GOOGLE-API-KEY\",\n * provider: \"geobytes\",\n * timestamp: 1466216325223\n * }\n */\n static locateByIP(options, callback) {\n // passed source can be a string or object\n let source = geolocator._.geoIpSource;\n\n if (!utils.isPlainObject(source)) {\n throw new GeoError(\n GeoError.Code.INVALID_GEO_IP_SOURCE,\n 'Please set a valid Geo-IP Source via geolocator.setGeoIPSource(options).'\n );\n }\n\n // check options and Google key\n checkGoogleKey(options || {});\n\n function updateResponse(response) {\n if (!response) {\n const err = new GeoError(GeoError.Code.INVALID_RESPONSE);\n return callback(err, null);\n }\n if (utils.isPlainObject(source.schema)) {\n response = utils.mapToSchema(response, source.schema);\n } else if (utils.isFunction(source.schema)) {\n response = source.schema(response);\n }\n response.provider = source.provider || 'unknown';\n setLocationURLs(response, options);\n if (response.coords) {\n response.coords.latitude = Number(response.coords.latitude);\n response.coords.longitude = Number(response.coords.longitude);\n }\n let cb = callbackMap(options, callback);\n fetchAddressAndTimezone(response, options, cb);\n }\n\n if (source.xhr) {\n let opts = {\n url: source.url,\n async: true\n };\n return fetch.get(opts, (err, xhr) => {\n const response = xhr.responseText ? JSON.parse(xhr.responseText) : null;\n if (err) return callback(GeoError.create(err), null);\n updateResponse(response);\n });\n\n }\n\n if (source.callbackParam || source.globalVar) {\n let jsonpOpts = {\n url: source.url,\n async: true,\n clean: true\n // params: {}\n };\n if (source.callbackParam) {\n jsonpOpts.callbackParam = source.callbackParam;\n jsonpOpts.rootName = 'geolocator._.cb';\n }\n return fetch.jsonp(jsonpOpts, (err, response) => {\n if (err) return callback(GeoError.create(err), null);\n if (source.globalVar) {\n if (window[source.globalVar]) {\n response = utils.clone(window[source.globalVar]);\n delete window[source.globalVar];\n } else {\n response = null;\n }\n }\n updateResponse(response);\n });\n }\n\n throw new GeoError(\n GeoError.Code.INVALID_GEO_IP_SOURCE,\n 'Either xhr, callbackParam or globalVar should be set for Geo-IP source.'\n );\n }\n\n /**\n * Sets the Geo-IP source to be used for fetching location information\n * by user's IP; which is internally used by\n * {@link #geolocator.locateByIP|`geolocator.locateByIP()` method}.\n *\n * By default, Geolocator uses a free Geo-IP source provider.\n * You can use this method to change this; or you can choose from\n * ready-to-use\n * {@link https://github.com/onury/geolocator/tree/master/src/geo-ip-sources|Geo-IP sources}.\n *\n * @param {Object} options\n * Geo-IP Source options.\n * @param {String} [options.provider]\n * Source or service provider's name.\n * @param {String} options.url\n * Source URL without the callback query parameter. The callback\n * name (if supported) should be set via `options.callbackParam`.\n * Also, make sure the service supports the protocol you use in\n * the enums.URL. If it supports both HTTP and HTTPS, you can omit the\n * protocol. In this case, it will be determined via Geolocator\n * configuration.\n * See {@link #geolocator.config|`geolocator.config()`}.\n * NOTE: Do not forget to include your API key in the query\n * parameters of the URL, if you have one.\n * @param {String} [options.callbackParam]\n * If JSON callback is supported, pass the name of the callback\n * parameter, defined by the provider.\n * @param {Object} [options.globalVar]\n * Set this instead of `options.callbackParam` if the service\n * does not support JSON callbacks, but weirdly set a global\n * variable in the document. For example, if the response is\n * `Geo = { lat, lng }`, you should set this to `\"Geo\"`.\n * @param {Object} [options.schema]\n * Schema object to be used to re-structure the response returned\n * from the service. Set the response object's keys as values of\n * a custom object to map the format to the `location` object.\n * For example; if the service returns a response like\n * `{ lat: 40.112233, lng: 10.112233, otherProp: 'hello' }`.\n * Then you should set the following schema:\n * `{ coords: { latitude: 'lat', longitude: 'lng' } }`.\n *\n * @return {geolocator}\n */\n static setGeoIPSource(options) {\n if (!utils.isPlainObject(options)) {\n throw new GeoError(GeoError.Code.INVALID_PARAMETERS, 'Geo-IP source options is invalid.');\n }\n if (!utils.isStringSet(options.url)) {\n throw new GeoError(GeoError.Code.INVALID_PARAMETERS, 'Geo-IP source should have a valid URI.');\n }\n // if (!utils.isStringSet(options.callbackParam) && !utils.isStringSet(options.globalVar)) {\n // throw new GeoError(GeoError.Code.INVALID_PARAMETERS, 'No \\'callbackParam\\' or \\'globalVar\\' is provided for the Geo-IP Source options.');\n // }\n geolocator._.geoIpSource = Object.freeze(options);\n }\n\n /**\n * Registers a handler for watching the user's location via HTML5\n * geolocation; that is triggered each time the position of the device\n * changes. This may require/prompt for user's permission.\n *\n * @param {Object} [options]\n * HTML5 geo-location settings.\n * @param {Boolean} [options.enableHighAccuracy=true]\n * Specifies whether the device should provide the most accurate\n * position it can. Note that setting this to `true` might consume\n * more CPU and/or battery power; and result in slower response\n * times.\n * @param {Number} [options.timeout=6000]\n * HTML5 position timeout setting in milliseconds. Setting this\n * to `Infinity` means that Geolocator won't return until the\n * position is available.\n * @param {Number} [options.maximumAge=0]\n * HTML5 position maximum age. Indicates the maximum age in\n * milliseconds of a possible cached position that is acceptable\n * to return. `0` means, the device cannot use a cached position\n * and must attempt to retrieve the real current position. If set\n * to `Infinity` the device must return a cached position\n * regardless of its age.\n * @param {Boolean} [options.clearOnError=false]\n * Specifies whether to clear the watcher on first error so that\n * it does not execute any more callbacks.\n * @param {Object} [options.target]\n * Object that defines the target location and settings; that\n * when the location is reached, the watcher will auto-clear\n * itself and invoke the callback.\n * @param {Number} options.target.latitude\n * The `latitude` of the target location.\n * @param {Number} options.target.longitude\n * The `longitude` of the target location.\n * @param {Number} [options.target.radius=0.5]\n * The radius, in other words; the minimum distance (in\n * kilometers or miles) to the target point that should be\n * reached.\n * @param {Number} [options.target.unitSystem=0]\n * Unit system to be used for target radius.\n * See {@link #geolocator.UnitSystem|`geolocator.UnitSystem` enumeration}\n * for possible values.\n * @param {Function} callback\n * Callback function to be executed when the request completes.\n * This takes 2 arguments: `function (err, location) { ... }`.\n * If `options.target` is set, `location` will also\n * include a `targetReached:Boolean` property.\n * See {@link #geolocator~Location|`geolocator~Location` type} for details.\n *\n * @returns {GeoWatcher} - A watcher object that provides a\n * `.clear(delay:Number, callback:Function)` method to clear the watcher\n * when needed. Optional `delay` argument can be set (in milliseconds) to\n * clear in a later time. Omitting this argument will clear the watcher\n * immediately. You should always call this method, except if you've set up\n * a target; which will auto-clear the watcher when reached.\n *\n * @example\n * // Watch my position for 5 minutes.\n * var options = { enableHighAccuracy: true, timeout: 6000, maximumAge: 0 };\n * var watcher = geolocator.watch(options, function (err, location) {\n * console.log(err || location);\n * });\n * console.log(watcher.id); // ID of the watcher\n * watcher.clear(300000); // clear after 5 minutes.\n *\n * @example\n * // Watch my position until I'm 350 meters near Disneyland Park.\n * options.target = {\n * latitude: 33.8120918,\n * longitude: -117.9233569,\n * radius: 0.35,\n * unitSystem: geolocator.UnitSystem.METRIC\n * };\n * watcher = geolocator.watch(options, function (err, location) {\n * if (err) {\n * console.log(err);\n * return;\n * }\n * if (location.targetReached) {\n * console.log(watcher.isCleared); // true\n * console.log(watcher.cycle); // 15 — target reached after 15 cycles\n * } else {\n * console.log(watcher.isCleared); // false — watcher is active.\n * }\n * });\n */\n static watch(options, callback) {\n if (!geolocator.isGeolocationSupported()) {\n callback(new GeoError(GeoError.Code.GEOLOCATION_NOT_SUPPORTED), null);\n return {};\n }\n\n let watcher, target;\n\n options = utils.extend({\n enableHighAccuracy: true,\n timeout: 6000,\n maximumAge: 0,\n clearOnError: false\n }, options);\n\n if (utils.isPlainObject(options.target)) {\n target = utils.extend({\n radius: 0.5,\n unitSystem: geolocator.UnitSystem.METRIC\n }, options.target);\n }\n\n function onPositionChanged(location) {\n let pos = utils.clone(location, { own: false });\n if (target) {\n let distance = geolocator.calcDistance({\n from: location.coords,\n to: target,\n formula: geolocator.DistanceFormula.HAVERSINE,\n unitSystem: target.unitSystem\n });\n pos.targetReached = distance <= target.radius;\n if (watcher && pos.targetReached) {\n watcher.clear(() => {\n return callback(null, pos);\n });\n }\n }\n return callback(null, pos);\n }\n function onPositionError(err) {\n callback(GeoError.create(err), null);\n }\n return new GeoWatcher(onPositionChanged, onPositionError, options);\n }\n\n /**\n * Converts a given address (or address components) into geographic\n * coordinates (i.e. latitude, longitude); and gets detailed address\n * information.\n * @see {@link https://developers.google.com/maps/documentation/geocoding/intro|Google Maps Geocoding API}\n * @see {@link https://developers.google.com/maps/documentation/geocoding/usage-limits|Usage Limits}\n *\n * @param {String|Object} options\n * Either the address to geocode or geocoding options with the\n * following properties.\n * @param {String} options.address\n * The street address to geocode, in the format used by the\n * national postal service of the country concerned. Additional\n * address elements such as business names and unit, suite or\n * floor numbers should be avoided. Note that any address\n * component (route, locality, administrativeArea, postalCode and\n * country) should be specified either in address or the\n * corresponding property - not both. Doing so may result in\n * `ZERO_RESULTS`.\n * @param {String} [options.route]\n * \t Long or short name of a route.\n * @param {String} [options.locality]\n * \t Locality and sublocality of the location.\n * @param {String} [options.administrativeArea]\n * \t Administrative area of the location.\n * @param {String} [options.postalCode]\n * \t Postal code of the location.\n * @param {String} [options.country]\n * \t A country name or a two letter ISO 3166-1 country code.\n * @param {String} [options.region]\n * \t The region code, specified as a ccTLD (\"top-level domain\")\n * \t two-character value. e.g.: `\"fr\"` for France.\n * @param {Array|Object} [options.bounds]\n * \t The bounding box of the viewport within which to bias geocode\n * \t results more prominently. e.g.:\n * \t `[ southwestLat:Number, southwestLng:Number, northeastLat:Number, northeastLng:Number ]`\n * @param {String|MapOptions} [options.map]\n * In order to create an interactive map from the fetched\n * location coordinates; either set this to a\n * {@link #geolocator~MapOptions|`MapOptions` object}\n * or; the ID of a DOM element or DOM element itself which the\n * map will be created within.\n * @param {Boolean|Object} [options.staticMap=false]\n * Set to `true` to get a static Google Map image URL (with\n * default options); or pass a static map options object.\n * @param {Boolean} [options.raw=false]\n * \t Whether to return the raw Google API result.\n * @param {Function} callback\n * Callback function to be executed when the request completes.\n * This takes 2 arguments: `function (err, location) { ... }`.\n * See {@link #geolocator~Location|`geolocator~Location` type} for details.\n *\n * @returns {void}\n *\n * @example\n * var address = '1600 Amphitheatre Parkway, CA';\n * geolocator.geocode(address, function (err, location) {\n * console.log(err || location);\n * });\n *\n * @example\n * // location result:\n * {\n * coords: {\n * latitude: 37.4224764,\n * longitude: -122.0842499\n * },\n * address: {\n * commonName: \"\",\n * street: \"Amphitheatre Pkwy\",\n * route: \"Amphitheatre Pkwy\",\n * streetNumber: \"1600\",\n * neighborhood: \"\",\n * town: \"\",\n * city: \"Mountain View\",\n * region: \"Santa Clara County\",\n * state: \"California\",\n * stateCode: \"CA\",\n * postalCode: \"94043\",\n * country: \"United States\",\n * countryCode: \"US\"\n * },\n * formattedAddress: \"1600 Amphitheatre Parkway, Mountain View, CA 94043, USA\",\n * type: \"ROOFTOP\",\n * placeId: \"ChIJ2eUgeAK6j4ARbn5u_wAGqWA\",\n * flag: \"//cdnjs.cloudflare.com/ajax/libs/flag-icon-css/2.3.1/flags/4x3/us.svg\",\n * map: {\n * element: HTMLElement,\n * instance: Object, // google.maps.Map\n * marker: Object, // google.maps.Marker\n * infoWindow: Object, // google.maps.InfoWindow\n * options: Object // map options\n * },\n * timestamp: 1456795956380\n * }\n */\n static geocode(options, callback) {\n geocode(false, options, callback);\n }\n\n /**\n * Converts the given geographic coordinates into a human-readable address\n * information.\n * @see {@link https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding|Google Maps (Reverse) Geocoding API}\n * @see {@link https://developers.google.com/maps/documentation/geocoding/usage-limits|Usage Limits}\n * @alias geolocator.addressLookup\n *\n * @param {Object|String} options\n * Either the `placeId` of the location or Reverse Geocoding options\n * with the following properties.\n * @param {Number} options.latitude\n * Latitude of the target location.\n * @param {Number} options.longitude\n * Longitude of the target location.\n * @param {String} [options.placeId]\n * Required if `latitude` and `longitude` are omitted. The place\n * ID of the place for which you wish to obtain the\n * human-readable address. The place ID is a unique identifier\n * that can be used with other Google APIs. Note that if\n * `placeId` is set, `latitude` and `longitude` are ignored.\n * @param {String|MapOptions} [options.map]\n * In order to create an interactive map from the fetched\n * location coordinates; either set this to a\n * {@link #geolocator~MapOptions|`MapOptions` object}\n * or; the ID of a DOM element or DOM element itself which the\n * map will be created within.\n * @param {Boolean|Object} [options.staticMap=false]\n * Set to `true` to get a static Google Map image URL (with\n * default options); or pass a static map options object.\n * @param {Boolean} [options.raw=false]\n * Whether to return the raw Google API result.\n * @param {Function} callback\n * Callback function to be executed when the request completes.\n * This takes 2 arguments: `function (err, location) { ... }`\n * See {@link #geolocator~Location|`geolocator~Location` type} for details.\n *\n * @returns {void}\n *\n * @example\n * var coords = {\n * latitude: 37.4224764,\n * longitude: -122.0842499\n * };\n *\n * geolocator.reverseGeocode(coords, function (err, location) {\n * console.log(err || location);\n * });\n *\n * @example\n * // location result:\n * {\n * coords: {\n * latitude: 37.4224764,\n * longitude: -122.0842499\n * },\n * address: {\n * commonName: \"\",\n * street: \"Amphitheatre Pkwy\",\n * route: \"Amphitheatre Pkwy\",\n * streetNumber: \"1600\",\n * neighborhood: \"\",\n * town: \"\",\n * city: \"Mountain View\",\n * region: \"Santa Clara County\",\n * state: \"California\",\n * stateCode: \"CA\",\n * postalCode: \"94043\",\n * country: \"United States\",\n * countryCode: \"US\"\n * },\n * formattedAddress: \"1600 Amphitheatre Parkway, Mountain View, CA 94043, USA\",\n * type: \"ROOFTOP\",\n * placeId: \"ChIJ2eUgeAK6j4ARbn5u_wAGqWA\",\n * flag: \"//cdnjs.cloudflare.com/ajax/libs/flag-icon-css/2.3.1/flags/4x3/us.svg\",\n * map: {\n * element: HTMLElement,\n * instance: Object, // google.maps.Map\n * marker: Object, // google.maps.Marker\n * infoWindow: Object, // google.maps.InfoWindow\n * options: Object // map options\n * },\n * timestamp: 1456795956380\n * }\n */\n static reverseGeocode(options, callback) {\n geocode(true, options, callback);\n }\n\n /**\n * Alias for `geolocator.reverseGeocode`\n * @private\n */\n static addressLookup(options, callback) {\n geolocator.reverseGeocode(options, callback);\n }\n\n /**\n * Gets timezone information for the given coordinates.\n * Note: Google Browser API keys cannot have referer restrictions when used with this API.\n * @see {@link https://developers.google.com/maps/documentation/timezone/intro|Google Maps TimeZone API}\n * @see {@link https://developers.google.com/maps/documentation/timezone/usage-limits|Usage Limits}\n *\n * @param {Object} options\n * Time zone options.\n * @param {Number} options.latitude\n * Latitude of location.\n * @param {Number} options.longitude\n * Longitude of location.\n * @param {Number} [options.timestamp=Date.now()]\n * Specifies the desired time as seconds since midnight, January\n * 1, 1970 UTC. This is used to determine whether or not Daylight\n * Savings should be applied.\n * @param {Boolean} [options.raw=false]\n * Whether to return the raw Google API result.\n * @param {Function} callback\n * Callback function to be executed when the request completes, in\n * the following signature: `function (err, timezone) { ... }`.\n * See {@link #geolocator~TimeZone|`geolocator~TimeZone` type} for\n * details.\n *\n * @returns {void}\n *\n * @example\n * var options = {\n * latitude: 48.8534100,\n * longitude: 2.3488000\n * };\n * geolocator.getTimeZone(options, function (err, timezone) {\n * console.log(err || timezone);\n * });\n *\n * @example\n * // timezone result:\n * {\n * id: \"Europe/Paris\",\n * name: \"Central European Standard Time\",\n * abbr: \"CEST\",\n * dstOffset: 0,\n * rawOffset: 3600,\n * timestamp: 1455733120\n * }\n */\n static getTimeZone(options, callback) {\n if (!utils.isPlainObject(options)\n || !utils.isNumber(options.latitude)\n || !utils.isNumber(options.longitude)) {\n throw new GeoError(GeoError.Code.INVALID_PARAMETERS);\n }\n\n checkGoogleKey();\n\n let conf = geolocator._.config;\n options = utils.extend({\n key: conf.google.key || '',\n language: conf.language || 'en',\n timestamp: utils.time(true),\n raw: false\n }, options);\n\n let url = utils.setProtocol(enums.URL.GOOGLE_TIMEZONE, conf.https),\n xhrOpts = {\n url: `${url}?location=${options.latitude},${options.longitude}×tamp=${options.timestamp}&language=${options.language}&key=${options.key}`\n };\n\n fetch.xhr(xhrOpts, (err, xhr) => {\n let response = getXHRResponse(err, xhr);\n if (GeoError.isGeoError(response)) return callback(response, null);\n\n response = options.raw ? response : {\n id: response.timeZoneId,\n name: response.timeZoneName,\n abbr: utils.abbr(response.timeZoneName, { dots: false }),\n dstOffset: response.dstOffset,\n rawOffset: response.rawOffset,\n timestamp: options.timestamp\n };\n callback(err, response);\n });\n }\n\n /**\n * Gets the distance and duration values based on the recommended route\n * between start and end points.\n * @see {@link https://developers.google.com/maps/documentation/distance-matrix/intro|Google Maps Distance Matrix API}\n * @see {@link https://developers.google.com/maps/documentation/distance-matrix/usage-limits|Usage Limits}\n *\n * @param {Object} options\n * Distance matrix options.\n * @param {String|Object|Array} options.origins\n * One or more addresses and/or an object of latitude/longitude\n * values, from which to calculate distance and time. If you pass\n * an address as a string, the service will geocode the string\n * and convert it to a latitude/longitude coordinate to calculate\n * distances. Following are valid examples:\n *
options.origins = 'London';\n     *  options.origins = ['London', 'Paris'];\n     *  options.origins = { latitude: 51.5085300, longitude: -0.1257400 };\n     *  options.origins = [\n     *      { latitude: 51.5085300, longitude: -0.1257400 },\n     *      { latitude: 48.8534100, longitude: 2.3488000 }\n     *  ];\n     *  
\n * @param {String|Object|Array} options.destinations\n * One or more addresses and/or an object of latitude/longitude\n * values, from which to calculate distance and time. If you pass\n * an address as a string, the service will geocode the string\n * and convert it to a latitude/longitude coordinate to calculate\n * distances.\n * @param {String} [options.travelMode=\"DRIVING\"]\n * Type of routing requested.\n * See {@link #geolocator.TravelMode|`geolocator.TravelMode` enumeration}\n * for possible values.\n * @param {Boolean} [options.avoidFerries]\n * If true, instructs the Distance Matrix service to avoid\n * ferries where possible.\n * @param {Boolean} [options.avoidHighways]\n * If true, instructs the Distance Matrix service to avoid\n * highways where possible.\n * @param {Boolean} [options.avoidTolls]\n * If true, instructs the Distance Matrix service to avoid toll\n * roads where possible.\n * @param {Number} [options.unitSystem=0]\n * Preferred unit system to use when displaying distance.\n * See {@link #geolocator.UnitSystem|`geolocator.UnitSystem` enumeration}\n * for possible values.\n * @param {String} [options.region]\n * Region code used as a bias for geocoding requests.\n * @param {Boolean} [options.raw=false]\n * Whether to return the raw Google API result.\n * @param {Function} callback\n * Callback function to be executed when the request completes,\n * in the following signature: `function (err, result) { ... }`\n *\n * @returns {void}\n *\n * @example\n * var options = {\n * origins: [{ latitude: 51.5085300, longitude: -0.1257400 }],\n * destinations: [{ latitude: 48.8534100, longitude: 2.3488000 }],\n * travelMode: geolocator.TravelMode.DRIVING,\n * unitSystem: geolocator.UnitSystem.METRIC\n * };\n * geolocator.getDistanceMatrix(options, function (err, result) {\n * console.log(err || result);\n * });\n *\n * @example\n * // result:\n * [\n * \t{\n * \t\tfrom: \"449 Duncannon St, London WC2R 0DZ, UK\",\n * \t\tto: \"1 Parvis Notre-Dame - Pl. Jean-Paul II, 75004 Paris-4E-Arrondissement, France\",\n * \t\tdistance: {\n * \t\t\tvalue: 475104,\n * \t\t\ttext: \"475 km\"\n * \t\t},\n * \t\tduration: {\n * \t\t\tvalue: 20193,\n * \t\t\ttext: \"5 hours 37 mins\"\n * \t\t},\n * \t\tfare: undefined,\n * \t\ttimestamp: 1456795956380\n * \t}\n * ]\n */\n static getDistanceMatrix(options, callback) {\n checkGoogleKey();\n\n let key = geolocator._.config.google.key;\n geolocator.ensureGoogleLoaded(key, err => {\n if (err) {\n throw new GeoError(GeoError.Code.GOOGLE_API_FAILED, String(err.message || err));\n }\n\n let o = options.origins || options.origin || options.from,\n d = options.destinations || options.destination || options.to;\n if (!utils.isPlainObject(options) || invalidOriginOrDest(o) || invalidOriginOrDest(d)) {\n throw new GeoError(GeoError.Code.INVALID_PARAMETERS);\n }\n options.origins = geoHelper.toPointList(o);\n options.destinations = geoHelper.toPointList(d);\n\n options = utils.extend({\n travelMode: google.maps.TravelMode.DRIVING,\n avoidFerries: undefined,\n avoidHighways: undefined,\n avoidTolls: undefined,\n unitSystem: google.maps.UnitSystem.METRIC\n }, options);\n\n let service = new google.maps.DistanceMatrixService();\n service.getDistanceMatrix(options, (response, status) => {\n let err = null;\n if (status !== google.maps.DistanceMatrixStatus.OK) {\n err = GeoError.fromResponse(status)\n || GeoError.fromResponse(response);\n response = null;\n } else {\n response = options.raw ? response : geoHelper.formatDistanceResults(response);\n }\n callback(err, response);\n });\n });\n }\n\n /**\n * Calculates the distance between two geographic points.\n *\n * @param {Object} options\n * Calculation and display options.\n * @param {Object} options.from\n * Object containing the `latitude` and `longitude` of original\n * location.\n * @param {Object} options.to\n * Object containing the `latitude` and `longitude` of destination.\n * @param {String} [options.formula=\"haversine\"]\n * The algorithm or formula to calculate the distance.\n * See {@link #geolocator.DistanceFormula|`geolocator.DistanceFormula` enumeration}.\n * @param {Number} [options.unitSystem=0]\n * Preferred unit system to use when displaying distance.\n * See {@link #geolocator.UnitSystem|`geolocator.UnitSystem` enumeration}.\n *\n * @returns {Number} - The calculated distance.\n *\n * @example\n * // Calculate distance from London to Paris.\n * var result = geolocator.calcDistance({\n * from: {\n * latitude: 51.5085300,\n * longitude: -0.1257400\n * },\n * to: {\n * latitude: 48.8534100,\n * longitude: 2.3488000\n * },\n * formula: geolocator.DistanceFormula.HAVERSINE,\n * unitSystem: geolocator.UnitSystem.METRIC\n * });\n * // result: 366.41656039126093 (kilometers)\n */\n static calcDistance(options) {\n options = utils.extend({\n formula: geolocator.DistanceFormula.HAVERSINE,\n unitSystem: geolocator.UnitSystem.METRIC\n }, options);\n\n let from = options.from,\n to = options.to,\n radius = options.unitSystem === geolocator.UnitSystem.METRIC\n ? EARTH_RADIUS_KM : EARTH_RADIUS_MI;\n\n if (options.formula === geolocator.DistanceFormula.HAVERSINE) {\n let dLat = geolocator.degToRad(to.latitude - from.latitude),\n dLng = geolocator.degToRad(to.longitude - from.longitude),\n a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +\n Math.cos(geolocator.degToRad(from.latitude)) *\n Math.cos(geolocator.degToRad(to.longitude)) *\n Math.sin(dLng / 2) * Math.sin(dLng / 2),\n c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n return radius * c;\n }\n // geolocator.DistanceFormula.PYTHAGOREAN\n let latA = geolocator.degToRad(from.latitude),\n latB = geolocator.degToRad(to.latitude),\n lngA = geolocator.degToRad(from.longitude),\n lngB = geolocator.degToRad(to.longitude),\n x = (lngB - lngA) * Math.cos((latA + latB) / 2),\n y = (latB - latA);\n return Math.sqrt(x * x + y * y) * radius;\n }\n\n /**\n * Gets the current public IP of the client.\n *\n * @param {Function} callback\n * Callback function to be executed when the request completes, in\n * the following signature: `function (err, result) { ... }`\n *\n * @returns {void}\n *\n * @example\n * geolocator.getIP(function (err, result) {\n * console.log(err || result);\n * });\n *\n * @example\n * // result:\n * {\n * ip: \"176.232.71.155\",\n * timestamp: 1457573683427\n * }\n */\n static getIP(callback) {\n let conf = geolocator._.config;\n\n // ipify.org supports CORS, so we'll use XMLHttpRequest instead of a\n // JSONP request.\n let opts = {\n url: utils.setProtocol(enums.URL.IP, conf.https),\n async: true\n };\n return fetch.get(opts, (err, xhr) => {\n const response = xhr.responseText;\n if (err) {\n return callback(GeoError.create(err), null);\n }\n if (!response) {\n err = new GeoError(GeoError.Code.INVALID_RESPONSE);\n return callback(err, null);\n }\n callback(null, {\n ip: response,\n timestamp: utils.time()\n });\n });\n // let jsonpOpts = {\n // url: utils.setProtocol(enums.URL.IP, conf.https),\n // async: true,\n // clean: true,\n // params: {\n // format: 'jsonp'\n // },\n // callbackParam: 'callback',\n // rootName: 'geolocator._.cb'\n // };\n // return fetch.jsonp(jsonpOpts, (err, response) => {\n // if (err) {\n // return callback(GeoError.create(err), null);\n // }\n // if (!response) {\n // err = new GeoError(GeoError.Code.INVALID_RESPONSE);\n // return callback(err, null);\n // }\n // if (typeof response === 'object') response.timestamp = utils.time();\n // callback(null, response);\n // });\n }\n\n /**\n * Ensures Google Maps API is loaded. If not, this will load all of the\n * main Javascript objects and symbols for use in the Maps API.\n *\n * Note that, Google Maps API is loaded only when needed. For example,\n * the DistanceMatrix API does not support Web Service requests and\n * requires this API to be loaded. However, the TimeZone API requests are\n * made throught the Web Service without requiring a `google` object\n * within DOM.\n *\n * Also note that this will not re-load the API if `google.maps` object\n * already exists. In this case, the `callback` is still executed and\n * no errors are passed.\n *\n * You can use the following overload to omit the `key` argument altogether:\n *\n * `geolocator.ensureGoogleLoaded(callback)`\n *\n * @param {String} [key]\n * Google API key.\n * @param {Function} callback\n * Callback function to be executed when the operation ends.\n *\n * @returns {void}\n *\n * @example\n * geolocator.ensureGoogleLoaded(function (err) {\n * if (err) return;\n * console.log('google' in window); // true\n * });\n */\n static ensureGoogleLoaded(key, callback) {\n let k;\n if (utils.isFunction(key)) {\n callback = key;\n } else {\n k = key;\n }\n if (!geolocator.isGoogleLoaded()) {\n let jsonpOpts = {\n url: enums.URL.GOOGLE_MAPS_API,\n async: true,\n callbackParam: 'callback',\n params: {\n key: k || ''\n // callback: ''\n },\n rootName: 'geolocator._.cb'\n };\n return fetch.jsonp(jsonpOpts, callback);\n }\n callback();\n }\n\n /**\n * Checks whether the Google Maps API is loaded.\n *\n * @returns {Boolean} - Returns `true` if already loaded.\n */\n static isGoogleLoaded() {\n return ('google' in window) && google.maps;\n }\n\n /**\n * Checks whether the type of the given object is an HTML5 `PositionError`.\n *\n * @param {*} obj - Object to be checked.\n * @return {Boolean}\n */\n static isPositionError(obj) {\n return utils.isPositionError(obj);\n }\n\n /**\n * Checks whether the given value is an instance of `GeoError`.\n *\n * @param {*} obj - Object to be checked.\n * @return {Boolean}\n */\n static isGeoError(obj) {\n return GeoError.isGeoError(obj);\n }\n\n /**\n * Checks whether HTML5 Geolocation API is supported.\n *\n * @return {Boolean}\n */\n static isGeolocationSupported() {\n return navigator && ('geolocation' in navigator);\n }\n\n /**\n * Converts kilometers to miles.\n *\n * @param {Number} km - Kilometers to be converted.\n * @returns {Number} - Miles.\n */\n static kmToMi(km) {\n return km * 0.621371;\n }\n\n /**\n * Converts miles to kilometers.\n *\n * @param {Number} mi - Miles to be converted.\n * @returns {Number} - Kilometers.\n */\n static miToKm(mi) {\n return mi / 0.621371;\n }\n\n /**\n * Converts degrees to radians.\n *\n * @param {Number} deg - Degrees to be converted.\n * @returns {Number} - Radians.\n */\n static degToRad(degrees) {\n return degrees * (Math.PI / 180);\n }\n\n /**\n * Converts radians to degrees.\n *\n * @param {Number} rad - Radians to be converted.\n * @returns {Number} - Degrees.\n */\n static radToDeg(radians) {\n return radians * (180 / Math.PI);\n }\n\n /**\n * Converts decimal coordinates (either lat or lng) to degrees, minutes, seconds.\n *\n * @param {Number} dec\n * Decimals to be converted.\n * @param {Boolean} [isLng=false]\n * Indicates whether the given decimals is longitude.\n *\n * @returns {String} - Degrees, minutes, seconds.\n */\n static decToDegMinSec(dec, isLng = false) {\n // Degrees Latitude must be in the range of -90. to 90.\n // Degrees Longitude must be in the range of -180 to 180.\n // +Latitude is North, -Latitude is South\n // +Longitude is East, -Longitude is West\n let sign = dec < 0 ? -1 : 1,\n sn = dec < 0 ? 'S' : 'N',\n we = dec < 0 ? 'W' : 'E',\n nsew = !isLng ? sn : we,\n absValue = Math.abs(Math.round(dec * 1000000.0));\n return ((Math.floor(absValue / 1000000) * sign) + '° ' + Math.floor(((absValue / 1000000) - Math.floor(absValue / 1000000)) * 60) + '\\' ' +\n (Math.floor(((((absValue / 1000000) - Math.floor(absValue / 1000000)) * 60) - Math.floor(((absValue / 1000000) - Math.floor(absValue / 1000000)) * 60)) * 100000) * 60 / 100000) + '\" ') + nsew;\n }\n\n}\n\n// ---------------------------\n// HELPER METHODS\n// ---------------------------\n\n/**\n * Used with distance matrix calls.\n * @private\n */\nfunction invalidOriginOrDest(value) {\n return !utils.isString(value)\n && !utils.isArray(value)\n && !utils.isPlainObject(value);\n}\n\n/**\n * Check if XHR response is an error response and returns a `GeoError`.\n * If not, returns the parsed response.\n * @private\n *\n * @param {Error} err\n * XHR error.\n * @param {Object} xhr\n * XHR object to be checked.\n *\n * @returns {GeoError|Object}\n */\nfunction getXHRResponse(err, xhr) {\n if (err) return GeoError.create(err);\n if (!xhr) return new GeoError(GeoError.Code.REQUEST_FAILED);\n let response = utils.safeJsonParse(xhr.responseText);\n // Check if XHR response is an error response.\n // return response if not.\n return GeoError.fromResponse(response) || response;\n}\n\n/**\n * Checks the given options and determines if Google key is required.\n * Throws if key is required but not set or valid.\n * @private\n *\n * @param {Object} [options]\n * Options to be checked. If `undefined`, directly checks Googke key.\n */\nfunction checkGoogleKey(options) {\n if (!options || (options.addressLookup || options.timezone || options.map || options.staticMap)) {\n if (!geolocator._.config.google.key) {\n throw new GeoError(GeoError.Code.GOOGLE_KEY_INVALID, 'A Google API key is required but it\\'s not set or valid.');\n }\n }\n}\n\n/**\n * Checks and adds necessary properties to map options from the given location\n * result object. This is used with methods that support `map` option; to\n * create a map from the result coordinates; such as locate() method.\n * @private\n *\n * @param {Object|String} options\n * Original options object.\n * @param {Object} location\n * Location result object.\n *\n * @returns {Object} - Final map options object.\n */\nfunction getMapOpts(mapOptions, location) {\n if (utils.isObject(mapOptions)) {\n mapOptions.center = location.coords;\n } else {\n mapOptions = {\n element: mapOptions,\n center: location.coords\n };\n }\n // this will enable infoWindow\n if (location.formattedAddress) {\n mapOptions.title = location.formattedAddress;\n }\n // if location has accuracy, (and zoom is not set) we can zoom in a bit more\n if (!mapOptions.zoom\n && location.coords\n && utils.isNumber(location.coords.accuracy)\n && location.coords.accuracy < 1500) {\n mapOptions.zoom = 15;\n }\n return mapOptions;\n}\n\n/**\n * Checks the HTMLElement to see whether a previous map and related objects\n * (marker, infoWindow) are created for it; by checking our private property\n * `_geolocatorMapData`. If there is a map, this does not re-create it (which\n * will break the map) but only re-adjust center, zoom and re-create the marker\n * if needed. We use this approach bec. Google maps has no feature to destroy\n * a map. This is considered a bug by Google developers.\n * @private\n *\n * @param {Object} options\n * Options for creating a map.\n */\nfunction configCreateMap(options) {\n let elem = options.element,\n // when geolocator creates a map, it will set a `_geolocatorMapData`\n // property on the element. So we can use this map instance later,\n // when the same HTMLElement is passed to create a map. So check if\n // we have it here.\n mapData = elem._geolocatorMapData,\n map = (mapData && mapData.instance) || null,\n marker = (mapData && mapData.marker) || null,\n infoWindow = (mapData && mapData.infoWindow) || null,\n center = new google.maps.LatLng(options.center.latitude, options.center.longitude),\n mapOptions = {\n mapTypeId: options.mapTypeId,\n center: center,\n zoom: options.zoom,\n styles: options.styles || null\n };\n\n // if we have a map, we'll just configure it. otherwise, we'll create\n // one.\n if (map) {\n map.setOptions(mapOptions);\n } else {\n map = new google.maps.Map(options.element, mapOptions);\n }\n\n // destroy marker and infoWindow if previously created for this element.\n if (infoWindow) infoWindow = null;\n if (marker && marker instanceof google.maps.Marker) {\n google.maps.event.clearInstanceListeners(marker);\n marker.setMap(null);\n marker = null;\n }\n\n // check the new options to see if we need to re-create a marker for\n // this.\n if (options.marker) {\n marker = new google.maps.Marker({\n position: mapOptions.center,\n map: map\n });\n if (options.title) {\n infoWindow = new google.maps.InfoWindow();\n infoWindow.setContent(options.title);\n // infoWindow.open(map, marker);\n google.maps.event.addListener(marker, 'click', () => {\n infoWindow.open(map, marker);\n });\n }\n }\n\n mapData = {\n element: elem,\n instance: map,\n marker: marker,\n infoWindow: infoWindow,\n options: mapOptions\n };\n // set the reference on the element for later use, if needed.\n elem._geolocatorMapData = mapData;\n return mapData;\n}\n\n/**\n * Sets the `flag` and `staticMap` (if enabled) property of the given location.\n * @private\n *\n * @param {Object} location - Fetched location result.\n * @param {Object} options - initial options.\n */\nfunction setLocationURLs(location, options) {\n if (!location || !location.address) return;\n let cc,\n address = location.address;\n if (utils.isString(address.countryCode) && address.countryCode.length === 2) {\n cc = address.countryCode;\n } else if (utils.isString(address.country) && address.country.length === 2) {\n cc = address.country;\n }\n if (!cc) return;\n location.flag = enums.URL.FLAG + cc.toLowerCase() + '.svg';\n if (options.staticMap) {\n let opts = utils.isPlainObject(options.staticMap)\n ? utils.clone(options.staticMap)\n : {};\n opts.center = location.coords;\n location.staticMap = geolocator.getStaticMap(opts);\n }\n}\n\n/**\n * Nests `createMap` callback within the given callback.\n * @private\n *\n * @param {Object} options\n * Method options.\n * @param {Function} callback\n * Parent callback.\n *\n * @returns {Function} - Nested callback.\n */\nfunction callbackMap(options, callback) {\n return function cb(err, location) {\n if (err) return callback(GeoError.create(err), null);\n setLocationURLs(location, options);\n if (!options.map) return callback(null, location);\n options.map = getMapOpts(options.map, location);\n geolocator.createMap(options.map, (error, map) => {\n if (error) return callback(error, null);\n location.map = map;\n return callback(null, location);\n });\n };\n}\n\n/**\n * Sends a geocode or reverse-geocode request with the given options.\n * @private\n *\n * @param {Boolean} reverse\n * Whether to send reverse-geocode request.\n * @param {Object} options\n * Geocode options.\n * @param {Function} callback\n * Callback to be nested and executed with map callback.\n */\nfunction geocode(reverse, options, callback) {\n checkGoogleKey();\n geoHelper.geocode(\n reverse,\n geolocator._.config,\n options,\n callbackMap(options, callback)\n );\n}\n\n/**\n * Runs both an address and a timezone look-up for the given location.\n * @private\n *\n * @param {Object} location\n * Location object.\n * @param {Object} options\n * Method options.\n * @param {Function} callback\n * Parent callback.\n */\nfunction fetchAddressAndTimezone(location, options, callback) {\n let loc = utils.clone(location, { own: false });\n if (!options.addressLookup && !options.timezone) {\n return callback(null, loc);\n }\n function getTZ(cb) {\n geolocator.getTimeZone(loc.coords, (err, timezone) => {\n if (err) {\n return cb(err, null);\n }\n delete timezone.timestamp;\n loc.timezone = timezone;\n loc.timestamp = utils.time(); // update timestamp\n cb(null, loc);\n });\n }\n if (options.addressLookup) {\n geolocator.reverseGeocode(loc.coords, (err, result) => {\n if (err) return callback(err, null);\n loc = utils.extend({}, result, loc);\n loc.address = result.address;\n loc.timestamp = utils.time(); // update timestamp\n if (!options.timezone) {\n callback(err, loc);\n } else {\n getTZ(callback);\n }\n });\n } else if (options.timezone) {\n getTZ(callback);\n } else {\n callback(null, loc);\n }\n}\n\n/**\n * Gets the position with better accuracy.\n * See https://github.com/gwilson/getAccurateCurrentPosition#background\n * @private\n *\n * @param {Object} options\n * Locate options.\n * @param {Function} onPositionReceived\n * Success callback.\n * @param {Function} onPositionError\n * Error callback.\n */\nfunction locateAccurate(options, onPositionReceived, onPositionError) {\n let loc,\n watcher,\n onProgress = !utils.isFunction(options.onProgress)\n ? utils.noop\n : options.onProgress;\n\n function complete() {\n watcher = null;\n if (!loc) {\n onPositionError(new GeoError(GeoError.Code.POSITION_UNAVAILABLE));\n } else {\n onPositionReceived(loc);\n }\n }\n\n watcher = geolocator.watch(options, (err, location) => {\n if (!watcher) return;\n if (err) {\n return watcher.clear(() => {\n onPositionError(err);\n });\n }\n loc = location;\n // ignore the first event if not the only result; for more accuracy.\n if (watcher.cycle > 1 && loc.coords.accuracy <= options.desiredAccuracy) {\n watcher.clear(complete);\n } else {\n onProgress(loc);\n }\n });\n if (watcher) watcher.clear(options.maximumWait + 100, complete);\n}\n\nfunction getStyles(options) {\n let conf = geolocator._.config;\n return !utils.isFilledArray(options.styles)\n ? (utils.isFilledArray(conf.google.styles) ? conf.google.styles : null)\n : options.styles;\n}\n\n// ---------------------------\n// INITIALIZE\n// ---------------------------\n\n/**\n * @private\n * @type {Object}\n */\ngeolocator._ = {\n config: utils.extend({}, defaultConfig),\n // Storage for global callbacks.\n cb: {}\n};\n\n// setting default Geo-IP source\n\ngeolocator.setGeoIPSource({\n provider: 'geojs.io',\n url: 'https://get.geojs.io/v1/ip/geo.json',\n xhr: true,\n schema: {\n ip: 'ip',\n coords: {\n latitude: 'latitude',\n longitude: 'longitude'\n },\n address: {\n city: 'city',\n state: 'region',\n stateCode: '',\n postalCode: '',\n countryCode: 'country_code',\n country: 'country',\n region: 'region'\n },\n timezone: {\n id: 'timezone'\n }\n }\n});\n\n// ---------------------------\n// EXPORT\n// ---------------------------\n\nexport { geolocator };\n\n// ---------------------------\n// ADDITIONAL DOCUMENTATION\n// ---------------------------\n\n/**\n * `Coordinates` inner type that specifies the geographic position of the\n * device. The position is expressed as a set of geographic coordinates\n * together with information about heading and speed.\n *\n * This is generally returned as part of the\n * {@link ?api=geolocator#geolocator~Location|`Location` result object}.\n *\n * @typedef geolocator~Coordinates\n * @type Object\n *\n * @property {Number} latitude\n * Specifies the latitude estimate in decimal degrees. The value\n * range is [-90.00, +90.00].\n * @property {Number} longitude\n * Specifies the longitude estimate in decimal degrees. The value\n * range is [-180.00, +180.00].\n * @property {Number} altitude\n * Specifies the altitude estimate in meters above the WGS 84\n * ellipsoid.\n * @property {Number} accuracy\n * Specifies the accuracy of the latitude and longitude estimates in\n * meters.\n * @property {Number} altitudeAccuracy\n * Specifies the accuracy of the altitude estimate in meters.\n * @property {Number} heading\n * Specifies the device's current direction of movement in degrees\n * counting clockwise relative to true north.\n * @property {Number} speed\n * Specifies the device's current ground speed in meters per second.\n */\n\n/**\n *\t`Address` inner type that specifies the address of the fetched location.\n *\tThe address is expressed as a set of political and locality components.\n *\n * This is generally returned as part of the\n * {@link ?api=geolocator#geolocator~Location|`Location` result object}.\n *\n * @typedef geolocator~Address\n * @type Object\n *\n * @property {String} commonName\n * Indicates a point of interest, a premise or colloquial area name for\n * the fetched location, if any.\n * @property {String} streetNumber\n * Indicates the precise street number of the fetched location, if any.\n * @property {String} street\n * Indicates the street name of the fetched location, if any.\n * @property {String} route\n * Indicates the route name of the fetched location, if any.\n * @property {String} neighborhood\n * Indicates the neighborhood name of the fetched location, if any.\n * @property {String} town\n * Indictes the town of the fetched location, if any.\n * @property {String} city\n * Indicates the city of the fetched location.\n * @property {String} region\n * Indicates the political region name of the fetched location, if any.\n * @property {String} postalCode\n * Indicates the postal code of the fetched location, if any.\n * @property {String} state\n * Indicates the state of the fetched location, if any.\n * @property {String} stateCode\n * Indicates the state code of the fetched location, if any.\n * @property {String} country\n * Indicates the national political entity of the fetched location.\n * @property {String} countryCode\n * Indicates the ISO alpha-2 country code of the fetched location.\n */\n\n/**\n *\t`TimeZone` inner type that specifies time offset data for the fetched\n *\tlocation on the surface of the earth.\n *\n * This is generally returned as part of the\n * {@link ?api=geolocator#geolocator~Location|`Location` result object}.\n *\n * @typedef geolocator~TimeZone\n * @type Object\n *\n * @property {String} id\n * The ID of the time zone, such as `\"America/Los_Angeles\"` or\n * `\"Australia/Sydney\"`. These IDs are defined in the\n * {@link http://www.iana.org/time-zones|IANA Time Zone Database},\n * which is also available in searchable format in Wikipedia's\n * {@link http://en.wikipedia.org/wiki/List_of_tz_database_time_zones|List of tz database time zones}.\n * @property {String} name\n * The long form name of the time zone. This field will be localized if\n * the Geolocator `language` is configured. e.g. `\"Pacific Daylight Time\"`\n * or `\"Australian Eastern Daylight Time\"`.\n * @property {String} abbr\n * The abbreviation of the time zone.\n * @property {Number} dstOffset\n * The offset for daylight-savings time in seconds. This will be zero\n * if the time zone is not in Daylight Savings Time during the specified\n * timestamp.\n * @property {Number} rawOffset\n * The offset from UTC (in seconds) for the given location. This does\n * not take into effect daylight savings.\n */\n\n/**\n *\t`MapData` inner type that provides references to the components of a\n *\tcreated Google Maps `Map` and the containing DOM element.\n *\n * This is generally returned as part of the\n * {@link ?api=geolocator#geolocator~Location|`Location` result object}.\n *\n * @typedef geolocator~MapData\n * @type Object\n *\n * @property {HTMLElement} element\n * DOM element which a (Google) map is created within.\n * @property {google.maps.Map} instance\n * Instance of a Google Maps `Map` object.\n * @property {google.maps.Marker} marker\n * Instance of a Google Maps `Marker` object, if any.\n * @property {google.maps.InfoWindow} infoWindow\n * Instance of a Google Maps `InfoWindow` object, if any.\n * @property {Object} options\n * Arbitrary object of applied map options.\n */\n\n/**\n *\t`Location` inner type that specifies geographic coordinates, address and\n *\ttime zone information for the fetched location.\n *\n * This result object is passed to the callbacks of the corresponding\n * asynchronous Geolocator methods (such as `.locate()` method), as the second\n * argument. The contents of this object will differ for various Geolocator\n * methods, depending on the configured method options.\n *\n * @typedef geolocator~Location\n * @type Object\n *\n * @property {Coordinates} coords\n * Specifies the geographic location of the device. The location is\n * expressed as a set of geographic coordinates together with\n * information about heading and speed.\n * See {@link #geolocator~Coordinates|`geolocator~Coordinates` type}\n * for details.\n * @property {Address} address\n * Specifies the address of the fetched location. The address is\n * expressed as a set of political and locality components.\n * This property might be `undefined` if `addressLookup` option is not\n * enabled for the corresponding method.\n * See {@link #geolocator~Address|`geolocator~Address` type}\n * for details.\n * @property {String} formattedAddress\n * The human-readable address of this location. Often this address is\n * equivalent to the \"postal address,\" which sometimes differs from\n * country to country.\n * @property {Boolean} targetReached\n * Specifies whether the defined target coordinates is reached.\n * This property is only available for\n * {@link #geolocator.watch|`geolocator.watch()`} method when `target`\n * option is defined.\n * @property {String} type\n * Type of the location. See\n * {@link #geolcoator.LocationType|`geolcoator.LocationType` enumeration}\n * for details.\n * @property {String} placeId\n * A unique identifier that can be used with other Google APIs.\n * @property {String} flag\n * URL of the country flag image, in SVG format. This property exists\n * only if address information is available.\n * @property {TimeZone} timezone\n * Specifies time offset data for the fetched location on the surface of\n * the earth. See {@link #geolocator~TimeZone|`geolocator~TimeZone` type}\n * for details.\n * @property {MapData} map\n * Provides references to the components of a created Google Maps `Map`\n * and the containing DOM element. See\n * {@link #geolocator~MapData|`geolocator~MapData` type} for details.\n * @property {String} staticMap\n * URL of a static Google map image, for the location.\n * @property {Number} timestamp\n * Specifies the time when the location information was retrieved and\n * the `Location` object created.\n */\n\n/**\n * `MapOptions` inner type that specifies options for the map to be created.\n *\n * @typedef geolocator~MapOptions\n * @type Object\n *\n * @property {String|HTMLElement|Map} element\n * Either the ID of a DOM element or the element itself;\n * which the map will be created within; or a previously created\n * `google.maps.Map` instance. If a map instance is set, this\n * only will apply the options without re-creating it.\n * @property {Object} center\n * Center coordinates for the map to be created.\n * @property {Number} center.latitude\n * Latitude of the center point coordinates.\n * @property {Number} center.longitude\n * Longitude of the center point coordinates.\n * @property {String} mapTypeId\n * Type of the map to be created.\n * See {@link #geolocator.MapTypeId|`geolocator.MapTypeId` enumeration}\n * for possible values.\n * @property {String} title\n * Title text to be displayed within an `InfoWindow`, when the\n * marker is clicked. This only take effect if `marker` is\n * enabled.\n * @property {Boolean} marker\n * Whether to place a marker at the given coordinates.\n * If `title` is set, an `InfoWindow` will be opened when the\n * marker is clicked.\n * @property {Number} zoom\n * Zoom level to be set for the map.\n */\n","// we don't mix import and module.exports in same file, so using require here.\nconst geolocator = require('./core/geolocator').geolocator;\n\n// See https://github.com/onury/geolocator/issues/42\nif (typeof window !== 'undefined'\n && typeof window.geolocator === 'undefined') {\n window.geolocator = geolocator;\n}\n\n// export default geolocator;\n// http://stackoverflow.com/a/33683495/112731\nmodule.exports = geolocator;\n","import utils from './utils';\n\n/**\n * Utility for making `XMLHttpRequest` and `JSONP` requests.\n * @copyright 2019, Onur Yıldırım \n */\nclass fetch {\n\n // https://html.spec.whatwg.org/multipage/scripting.html#script\n\n /**\n * Makes a JSONP (GET) request by injecting a script tag in the browser.\n * Note that using JSONP has some security implications. As JSONP is really\n * javascript, it can do everything else javascript can do, so you need to\n * trust the provider of the JSONP data.\n * @see https://en.wikipedia.org/wiki/JSONP\n * @memberof fetch\n *\n * @param {Object|String} options - Required. Either the URL string which\n * will set other options to defaults or an options object with the\n * following properties.\n * @param {String} options.url\n * Source URL to be called.\n * @param {String} [options.type]\n * The MIME type that identifies the scripting language of the\n * code referenced within the script element.\n * e.g. `\"text/javascript\"`\n * @param {String} [options.charset]\n * Indicates the character encoding of the external resource.\n * e.g. `\"utf-8\"`.\n * @param {Boolean} [options.async=true]\n * Indicates whether or not to perform the operation\n * asynchronously. See {@link http://caniuse.com/#feat=script-async|browser support}.\n * @param {Boolean} [options.defer=false]\n * Indicates whether the script should be executed when the page\n * has finished parsing. See {@link http://caniuse.com/#feat=script-defer|browser support}.\n * @param {String} [options.crossorigin]\n * Indicates the CORS setting for the script element being\n * injected. Note that this attribute is not widely supported.\n * Valid values: `\"anonymous\"`, `\"use-credentials\"`.\n * See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes|CORS settings}.\n * @param {Number} [options.timeout=0]\n * The number of milliseconds a request can take before\n * automatically being terminated. `0` disables timeout.\n * @param {Boolean} [options.clean=false]\n * Whether to remove the loaded script from DOM when the\n * operation ends. Note that the initial source might load\n * additional sources which are not deteceted or removed. Only\n * the initial source is removed.\n * @param {Object} [options.params]\n * Optional query parameters to be appended at the end of the URL.\n * e.g. `{ key: \"MY-KEY\" }`\n * You can also include the JSONP callback name parameter here\n * but if you want the object to be passed to the callback\n * argument of this method, use `options.callbackParam` to set\n * the callback parameter.\n * @param {String} [options.callbackParam]\n * If the endpoint supports JSONP callbacks, you can set the\n * callback parameter with this setting. This will enable a\n * second `obj` argument in the callback of this method which is\n * useful if the JSONP source invokes the callback with an\n * argument.\n * @param {String} [options.rootName]\n * The name (or notation) of the object that the generated JSONP\n * callback function should be assigned to. By default, this is\n * the `window` object but you can set this to a custom object\n * notation; for example, to prevent global namespace polution.\n * Note that this root object has to be globally accessible for\n * this to work. e.g. `\"window.myObject\"` (as string)\n * @param {Function} [callback]\n * The callback function that will be executed when the script is\n * loaded. This callback has the following signature:\n * `function (err, obj) { ... }`. Note that the second argument\n * `obj` will always be `undefined` if the source endpoint does not\n * support JSONP callbacks or a callback param is not set explicitly\n * via `options.callbackParam` (or if the source does not invoke the\n * jsonp with an argument). However, the function will always execute\n * when the script loads or an error occurs.\n *\n * @returns {void}\n *\n * @example\n * var opts1 = {\n * \t url: 'some/api',\n * \t callbackParam: 'jsonCallback',\n * \t params: { key: 'MY-KEY' }\n * };\n * // This will load the following source:\n * // some/api?jsonCallback={auto-generated-fn-name}&key=MY-KEY\n * fetch.jsonp(opts1, function (err, obj) {\n * \t console.log(obj); // some object\n * });\n *\n * var opts2 = {\n * \t url: 'some/api',\n * \t params: {\n * \t\t key: 'MY-KEY',\n * \t\t jsonCallback: 'my-fn-name'\n * \t }\n * };\n * // This will load the following source:\n * // some/api?jsonCallback=my-fn-name&key=MY-KEY\n * fetch.jsonp(options, function (err, obj) {\n * \t console.log(obj); // undefined\n * \t // still executes, catch errors here\n * });\n * // JSON callback should be explicitly set.\n * window['my-fn-name'] = function (obj) {\n * \t console.log(obj); // some object\n * };\n */\n static jsonp(options, callback) {\n let timeout;\n\n callback = utils.isFunction(callback)\n ? callback\n : utils.noop;\n\n if (utils.isString(options)) {\n options = { url: options };\n }\n\n if (utils.isPlainObject(options)) {\n options = utils.extend({\n // type: undefined,\n async: true,\n defer: false,\n // crossorigin: undefined,\n timeout: 0,\n params: {},\n // callbackParam: undefined,\n // rootName: undefined,\n clean: true\n }, options);\n } else {\n return callback(new Error('No options or target URL is provided.'));\n }\n\n if (utils.isString(options.url) === false || options.url.trim() === '') {\n return callback(new Error('No target URL is provided.'));\n }\n\n let script = document.createElement('script'),\n cbParamSet = utils.isString(options.callbackParam)\n && options.callbackParam.trim() !== '',\n cbFnName,\n root,\n rootNameSet = utils.isString(options.rootName)\n && options.rootName !== 'window'\n && options.rootName !== 'document'\n && options.rootName.trim() !== '';\n\n if (cbParamSet) {\n cbFnName = '_jsonp_' + utils.randomString(10);\n options.params[options.callbackParam] = rootNameSet\n ? `${options.rootName}.${cbFnName}`\n : cbFnName;\n }\n let query = utils.params(options.params) || '',\n qMark = options.url.indexOf('?') >= 0 ? '&' : '?',\n url = query ? `${options.url}${qMark}${query}` : options.url;\n // console.log(url);\n\n function execCb(err, timeUp, obj) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n if ((timeUp || options.clean) && script.parentNode) {\n script.parentNode.removeChild(script);\n }\n // delete the jsonp callback function\n if (rootNameSet) {\n delete root[cbFnName];\n }\n callback(err, obj);\n }\n\n if (cbFnName) {\n let fn = obj => {\n execCb(null, false, obj);\n };\n root = rootNameSet\n // ? window[options.rootName][cbFnName] = fn;\n ? utils.notateGlobalObj(options.rootName) // if rootName is dot-notation.\n : window;\n root[cbFnName] = fn;\n } else if (script.readyState) { // IE < 11\n script.onreadystatechange = () => {\n if (script.readyState === 'loaded'\n || script.readyState === 'complete') {\n script.onreadystatechange = null;\n execCb(null);\n }\n };\n } else { // IE 11+\n script.onload = () => {\n execCb(null);\n };\n }\n\n script.onerror = error => {\n let errMsg = 'Could not load source at ' + utils.removeQuery(options.url);\n if (error) {\n errMsg += '\\n' + (error.message || error);\n }\n execCb(new Error(errMsg));\n };\n\n if (options.type) {\n script.type = options.type;\n }\n if (options.charset) {\n script.charset = options.charset;\n }\n if (options.async) {\n script.async = true;\n }\n if (options.defer) {\n script.defer = true;\n }\n if (options.crossorigin) {\n script.crossorigin = options.crossorigin;\n }\n\n script.src = url;\n document.getElementsByTagName('head')[0].appendChild(script);\n\n // Timeout\n if (utils.isNumber(options.timeout) && options.timeout > 0) {\n timeout = setTimeout(() => {\n script.src = '';\n execCb(new Error('Operation timed out.'), true);\n }, options.timeout);\n }\n }\n\n /**\n * Makes an XMLHttpRequest with the given parameters.\n * Note that `\"Access-Control-Allow-Origin\"` header should be present on\n * the requested resource. Otherwise, the request will not be allowed.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest|XMLHttpRequest}.\n * @memberof fetch\n *\n * @param {Object|String} options\n * Either the URL string which will set other options to defaults or\n * the full options object.\n * @param {String} options.url\n * Target URL to be called.\n * @param {String} [options.method=\"GET\"]\n * HTTP method.\n * @param {*} [options.data]\n * Data to be sent with the request.\n * @param {Number} [options.timeout]\n * The number of milliseconds a request can take before\n * automatically being terminated. `0` disables timeout.\n * @param {Boolean} [options.withCredentials=false]\n * Indicates whether or not cross-site Access-Control requests\n * should be made using credentials such as cookies or\n * authorization headers.\n * @param {Boolean} [options.async=true]\n * Indicating whether or not to perform the operation\n * asynchronously. If this value is false, the `send()` method\n * does not return until the response is received. If `true`,\n * notification of a completed transaction is provided using\n * event listeners. This must be `true` if the multipart\n * attribute is `true`, or an exception will be thrown.\n * @param {String} [options.mimeType]\n * If set, overrides the MIME type returned by the server. This\n * may be used, for example, to force a stream to be treated and\n * parsed as `text/xml`, even if the server does not report it as\n * such.\n * @param {Object} [options.headers]\n * Sets the HTTP request headers. Each key should be a header\n * name with a value. e.g. `{ 'Content-Length': 50 }`. For\n * security reasons, some headers cannot be set and can only be\n * controlled by the user agent.\n * @param {String} [options.username=\"\"]\n * User name to use for authentication purposes.\n * @param {String} [options.password=\"\"]\n * Password to use for authentication purposes.\n * @param {Function} [callback]\n * The callback function in the following signature:\n * `function (err, xhr) { ... }`\n * Note that `xhr` object is always passed regardless of an error.\n *\n * @returns {void}\n */\n static xhr(options, callback) {\n let xhr, err;\n let isXDR = false;\n\n if ('XMLHttpRequest' in window) {\n xhr = new XMLHttpRequest();\n } else if ('XDomainRequest' in window) { // IE9\n xhr = new XDomainRequest();\n isXDR = true;\n } else {\n throw new Error('XMLHttpRequest is not supported!');\n }\n\n let hasCallback = utils.isFunction(callback);\n callback = hasCallback\n ? callback\n : utils.noop;\n\n if (utils.isString(options)) options = { url: options };\n if (utils.isPlainObject(options)) {\n options = utils.extend({\n method: 'GET',\n data: undefined,\n async: true,\n timeout: 0, // no timeout\n withCredentials: false,\n mimeType: undefined,\n username: '',\n password: ''\n }, options);\n } else {\n callback(new Error('No options or target URL is provided.'));\n }\n\n if (utils.isString(options.url) === false) {\n callback(new Error('No target URL is provided.'));\n }\n\n options.username = String(options.username);\n options.password = String(options.password);\n options.method = options.method.toUpperCase();\n if (options.method !== 'POST' && options.method !== 'PUT') {\n options.data = undefined;\n }\n // console.log(JSON.stringify(options));\n\n function xError() {\n let crossDomain = xhr.status === 0\n ? '. Make sure you have permission if this is a cross-domain request.'\n : '';\n err = new Error(`The request returned status: ${xhr.status}${crossDomain}`);\n // console.log(xhr);\n callback(err, xhr);\n }\n\n if (hasCallback) {\n if (isXDR) { // IE9\n xhr.onload = () => {\n callback(null, xhr);\n };\n xhr.onerror = xError;\n } else {\n xhr.onreadystatechange = () => {\n if (xhr.readyState === fetch.XHR_READY_STATE.DONE) {\n if (xhr.status === 200) {\n callback(null, xhr);\n } else {\n xError();\n }\n }\n };\n }\n\n if (utils.isNumber(options.timeout) && options.timeout > 0) {\n xhr.timeout = options.timeout;\n xhr.ontimeout = () => {\n // xhr.abort();\n err = new Error('The request had timed out.');\n callback(err, xhr);\n };\n }\n }\n // console.log(options);\n xhr.open(options.method, options.url, options.async, options.username, options.password);\n\n // if this is XDomainRequest, it doesn't support setting custom headers;\n // or overriding the mime type.\n if (!isXDR) {\n if (utils.isPlainObject(options.headers)) {\n // xhr.setRequestHeader() method should be called after open(), but\n // before send().\n Object.keys(options.headers).forEach(key => {\n let value = options.headers[key];\n xhr.setRequestHeader(key, value);\n });\n }\n\n // xhr.overrideMimeType() method must be called before send().\n if (options.mimeType) {\n xhr.overrideMimeType(options.mimeType);\n }\n }\n\n xhr.send(options.data);\n }\n\n /**\n * Alias of `fetch.xhr()` with request method set to `\"GET\"` by default.\n * @memberof fetch\n *\n * @param {Object} options\n * Either the URL string which will set other options to defaults or\n * the full options object. See `fetch.xhr()` method options for\n * details.\n * @param {Function} [callback]\n * The callback function in the following signature:\n * `function (err, xhr) { ... }`\n * Note that `xhr` object is always passed regardless of an error.\n * @returns {void}\n */\n static get(options, callback) {\n return fetch.xhr(options, callback);\n }\n\n /**\n * Alias of `fetch.xhr()` with request method set to `\"POST\"` by default.\n * @memberof fetch\n *\n * @param {Object} options\n * Either the URL string which will set other options to defaults or\n * the full options object. See `fetch.xhr()` method options for\n * details.\n * @param {Function} [callback]\n * The callback function in the following signature:\n * `function (err, xhr) { ... }`\n * Note that `xhr` object is always passed regardless of an error.\n * @returns {void}\n */\n static post(options, callback) {\n return _xhr('POST', options, callback);\n }\n\n /**\n * Alias of `fetch.xhr()` with request method set to `\"PUT\"` by default.\n * @memberof fetch\n *\n * @param {Object} options\n * Either the URL string which will set other options to defaults or\n * the full options object. See `fetch.xhr()` method options for\n * details.\n * @param {Function} [callback]\n * The callback function in the following signature:\n * `function (err, xhr) { ... }`\n * Note that `xhr` object is always passed regardless of an error.\n * @returns {void}\n */\n static put(options, callback) {\n return _xhr('PUT', options, callback);\n }\n\n /**\n * Alias of `fetch.xhr()` with request method set to `\"DELETE\"` by default.\n * @memberof fetch\n *\n * @param {Object} options\n * Either the URL string which will set other options to defaults or\n * the full options object. See `fetch.xhr()` method options for\n * details.\n * @param {Function} [callback]\n * The callback function in the following signature:\n * `function (err, xhr) { ... }`\n * Note that `xhr` object is always passed regardless of an error.\n * @returns {void}\n */\n static delete(options, callback) {\n return _xhr('DELETE', options, callback);\n }\n}\n\n/**\n * @private\n */\nfunction _xhr(method, options, callback) {\n options = utils.isString(options)\n ? { url: options }\n : options || {};\n options.method = method;\n return fetch.xhr(options, callback);\n}\n\n/**\n * Enumerates `XMLHttpRequest` ready states.\n * Not to be confused with `script.readyState`.\n * @memberof fetch\n *\n * @enum {Number}\n */\nfetch.XHR_READY_STATE = {\n /**\n * `xhr.open()` has not been called yet.\n * @type {Number}\n */\n UNSENT: 0,\n /**\n * `xhr.send()` has been called.\n * @type {Number}\n */\n OPENED: 1,\n /**\n * `xhr.send()` has been called, and headers and status are available.\n * @type {Number}\n */\n HEADERS_RECEIVED: 2,\n /**\n * Downloading; responseText holds partial data.\n * @type {Number}\n */\n LOADING: 3,\n /**\n * The operation is complete.\n * @type {Number}\n */\n DONE: 4\n};\n\nexport default fetch;\n","let _toString = Object.prototype.toString;\n\n/**\n * Simple utility methods; internally used within Geolocator core;\n * made publically accessible.\n * @type {Object}\n * @readonly\n */\nconst utils = {\n\n noop() {},\n\n // ---------------------------\n // Validation\n // ---------------------------\n\n /**\n * Checks if the type of the given value is `String`.\n * @memberof utils\n *\n * @param {*} value - Value to be checked.\n * @returns {Boolean}\n */\n isString(value) {\n return typeof value === 'string';\n },\n\n isStringSet(value) {\n return typeof value === 'string' && value.trim().length > 0;\n },\n\n /**\n * Checks if the type of the given value is `Number`.\n * @memberof utils\n *\n * @param {*} value - Value to be checked.\n * @returns {Boolean}\n */\n isNumber(value) {\n return typeof value === 'number';\n },\n\n /**\n * Checks if the type of the given value is an `Object` or `Function`.\n * @memberof utils\n *\n * @param {*} value - Value to be checked.\n * @returns {Boolean}\n */\n isObject(value) {\n let type = typeof value;\n return Boolean(value) && (type === 'object' || type === 'function');\n },\n\n /**\n * Checks if the type of the given value is `Function`.\n * @memberof utils\n *\n * @param {*} value - Value to be checked.\n * @returns {Boolean}\n */\n isFunction(value) {\n return typeof value === 'function';\n },\n\n /**\n * Checks if the type of the given value is `Array`.\n * @memberof utils\n *\n * @param {*} value - Value to be checked.\n * @returns {Boolean}\n */\n isArray(value) {\n return Boolean(value) && _toString.call(value) === '[object Array]';\n },\n\n /**\n * Checks if the given object is a non-empty `Array`.\n * @memberof utils\n *\n * @param {*} array - Object to be checked.\n * @returns {Boolean}\n */\n isFilledArray(array) {\n return utils.isArray(array) && array.length > 0;\n },\n\n /**\n * Checks if the given value is a plain `Object`.\n * @memberof utils\n *\n * @param {*} value - Value to be checked.\n * @returns {Boolean}\n */\n isPlainObject(value) {\n return Boolean(value)\n && typeof value === 'object'\n && _toString.call(value) === '[object Object]';\n },\n\n /**\n * Checks if the given value is a `Date`.\n * @memberof utils\n *\n * @param {*} value - Value to be checked.\n * @returns {Boolean}\n */\n isDate(value) {\n return Boolean(value) && _toString.call(value) === '[object Date]';\n },\n\n /**\n * Checks if the given object is a DOM element.\n * @memberof utils\n *\n * @param {Object} object - Object to be checked.\n * @returns {Boolean}\n */\n isElement(object) {\n if (!object) return false;\n return object instanceof HTMLElement\n || (typeof object === 'object' && object.nodeType === 1);\n },\n\n /**\n * Checks if the given object is a DOM node.\n * @memberof utils\n *\n * @param {Object} object - Object to be checked.\n * @returns {Boolean}\n */\n isNode(object) {\n if (!object) return false;\n return object instanceof Node\n || (typeof object === 'object' && typeof object.nodeType === 'number');\n },\n\n /**\n * Checks if the given object is a jQuery instance.\n * This will still return `false` if the jQuery instance has no items.\n * @memberof utils\n *\n * @param {Object} object - Object to be checked.\n * @returns {Boolean}\n */\n isJQueryObject(object) {\n if (!object) return false;\n return ('jQuery' in window && object instanceof window.jQuery && Boolean(object[0]));\n // http://api.jquery.com/jquery-2/\n // || (typeof object === 'object' && Boolean(object.jquery));\n },\n\n /**\n * Checks if the type of the given value is an HTML5 `PositionError`.\n * @memberof utils\n *\n * @param {*} value - Value to be checked.\n * @returns {Boolean}\n */\n isPositionError(value) {\n return Boolean(value) && _toString.call(value) === '[object PositionError]';\n },\n\n /**\n * Checks if the given value is an instance of `Error` or HTML5 `PositionError`.\n * @memberof utils\n *\n * @param {*} value - Value to be checked.\n * @returns {Boolean}\n */\n isError(value) {\n return (value instanceof Error) || utils.isPositionError(value);\n },\n\n // ---------------------------\n // String\n // ---------------------------\n\n /**\n * Removes the query string portion from the given URL string.\n * @memberof utils\n *\n * @param {String} str - String to be processed.\n * @returns {String} - Returns the rest of the string.\n */\n removeQuery(str) {\n return str.replace(/\\?.*$/, '');\n },\n\n /**\n * Removes the protocol portion from the given URL string.\n * @memberof utils\n *\n * @param {String} str - String to be processed.\n * @returns {String} - Returns the rest of the string.\n */\n removeProtocol(str) {\n return str.replace(/^(.*:)?\\/\\//, '');\n },\n\n /**\n * Sets the protocol of the given URL.\n * @memberof utils\n *\n * @param {String} url\n * The URL to be modified.\n * @param {Boolean} [https]\n * Specifies whether to set the protocol to HTTPS.\n * If omitted, current page protocol will be used.\n *\n * @returns {String} - The modified URL string.\n */\n setProtocol(url, https) {\n let p;\n if (https === undefined || https === null) {\n p = window.location.protocol;\n } else {\n p = https ? 'https:' : 'http:';\n }\n url = utils.removeProtocol(url);\n return `${p}//${url}`;\n },\n\n /**\n * Removes both the leading and trailing dots from the given string.\n * @memberof utils\n *\n * @param {String} str - String to be processed.\n * @returns {String} - Returns the rest of the string.\n */\n trimDots(str) {\n return str.replace(/^\\.+?(.*?)\\.+?$/g, '$1');\n },\n\n /**\n * URL-Encodes the given string. Note that the encoding is done Google's\n * way; that is, spaces are replaced with `+` instead of `%20`.\n * @memberof utils\n *\n * @param {String} str - String to be processed.\n * @returns {String} - Returns the encoded string.\n */\n encodeURI(str) {\n return encodeURIComponent(str).replace(/%20/g, '+');\n },\n\n /**\n * URL-Decodes the given string. This is the reverse of `utils.encodeURI()`;\n * so pluses (`+`) are replaced with spaces.\n * @memberof utils\n *\n * @param {String} str - String to be processed.\n * @returns {String} - Returns the decoded string.\n */\n decodeURI(str) {\n return decodeURIComponent(str.replace(/\\+/g, '%20'));\n },\n\n /**\n * Converts the given value to string.\n * `null` and `undefined` converts to empty string.\n * If value is a function, it's native `toString()` method is used.\n * Otherwise, value is coerced.\n * @memberof utils\n *\n * @param {*} value - String to be converted.\n * @returns {String} - Returns the result string.\n */\n toString(value) {\n if (value === null || value === undefined) return '';\n if (value.toString && utils.isFunction(value.toString)) {\n return value.toString();\n }\n return String(value);\n },\n\n /**\n * Generates a random string with the number of characters.\n * @memberof utils\n *\n * @param {Number} [len=1] - Length of the string.\n * @returns {String} - Returns a random string.\n */\n randomString(len) {\n if (!len || !utils.isNumber(len)) len = 1;\n len = -Math.abs(len);\n return Math.random().toString(36).slice(len);\n },\n\n /**\n * Gets the abbreviation of the given phrase.\n * @memberof utils\n *\n * @param {String} str\n * String to abbreviate.\n * @param {Object} [options]\n * Abbreviation options.\n * @param {Boolean} [options.upper=true]\n * Whether to convert to upper-case.\n * @param {Boolean} [options.dots=true]\n * Whether to add dots after each abbreviation.\n *\n * @returns {String} - Returns the abbreviation of the given phrase.\n */\n abbr(str, options) {\n options = utils.extend({\n upper: true,\n dots: true\n }, options);\n let d = options.dots ? '.' : '',\n s = str.match(/(\\b\\w)/gi).join(d) + d;\n return options.upper ? s.toUpperCase() : s;\n },\n\n /**\n * Builds URI parameters from the given object.\n * Note: This does not iterate deep objects.\n * @memberof utils\n *\n * @param {Object} obj - Object to be processed.\n * @param {Object} options - Parameterize options.\n * @param {Boolean} [options.encode=true]\n * Whether to encode URI components.\n * @param {String} [options.operator=\"=\"]\n * @param {String} [options.separator=\"&\"]\n * @param {Array} [options.include]\n * Keys to be included in the output params. If defined,\n * `options.exclude` is ignored.\n * @param {Array} [options.exclude]\n * Keys to be excluded from the output params.\n *\n * @returns {String} - URI parameters string.\n */\n params(obj, options) {\n if (!utils.isPlainObject(obj) || Object.keys(obj).length === 0) {\n return '';\n }\n\n options = utils.extend({\n encode: true,\n operator: '=',\n separator: '&',\n include: undefined,\n exclude: undefined\n }, options);\n\n let params = [],\n inc = utils.isArray(options.include) ? options.include : null,\n exc = !inc && utils.isArray(options.exclude) ? options.exclude : null;\n utils.forIn(obj, (value, key) => {\n if ((!inc || inc.indexOf(key) >= 0)\n && (!exc || exc.indexOf(key) < 0)) {\n let v = utils.toString(value);\n v = options.encode ? utils.encodeURI(v) : v;\n let k = options.encode ? utils.encodeURI(key) : key;\n params.push(k + options.operator + v);\n }\n });\n\n return params.join(options.separator);\n },\n\n /**\n * Gets the object from the given object notation string.\n * @private\n *\n * @param {String} notation - Object notation.\n * @returns {*} - Any existing object.\n */\n notateGlobalObj(notation) {\n notation = utils.trimDots(notation);\n let levels = notation.split('.'),\n o = window;\n if (levels[0] === 'window' || levels[0] === 'document') {\n levels.shift();\n }\n levels.forEach(note => {\n o = o[note];\n });\n return o;\n },\n\n // ---------------------------\n // Object\n // ---------------------------\n\n /**\n * Iterates over own properties of an object invoking a callback for each\n * property.\n * @memberof utils\n *\n * @param {Object} obj\n * Object to be processed.\n * @param {Function} callback\n * Callback function with the following signature:\n * `function (value, key, object) { ... }`.\n * Explicitly returning `false` will exit the iteration early.\n * @returns {void}\n */\n forIn(obj, callback) {\n let k;\n for (k in obj) {\n // if (obj.hasOwnProperty(k)) {} // Do this inside callback if needed.\n if (callback(obj[k], k, obj) === false) break;\n }\n },\n\n /**\n * Extends the given object with the specified sources.\n * Right most source overwrites the previous.\n * NOTE: This is not a full implementation. Use with caution.\n * @memberof utils\n *\n * @param {Object} destination\n * Destionation Object that will be extended and holds the default\n * values.\n * @param {...Object} sources\n * Source objects to be merged.\n *\n * @returns {Object} - Returns the extended object.\n */\n extend(destination, ...sources) {\n if (!utils.isObject(destination)) return {};\n let key, value;\n sources.forEach(source => {\n for (key in source) { // eslint-disable-line\n value = source[key];\n if (utils.isArray(value)) {\n destination[key] = value.concat();\n } else if (utils.isDate(value)) {\n destination[key] = new Date(value);\n } else if (utils.isFunction(value)) { // should be before object\n destination[key] = value;\n } else if (utils.isObject(value)) {\n destination[key] = utils.extend({}, value);\n } else {\n destination[key] = value;\n }\n }\n });\n return destination;\n },\n\n /**\n * Clones the given object.\n * NOTE: This is not a full implementation. Use with caution.\n * @memberof utils\n *\n * @param {Object} obj\n * Target Object to be cloned.\n * @param {Object|Array} [options]\n * Clone options or array of keys to be cloned.\n * @param {Array} [options.keys]\n * Keys of the properties to be cloned.\n * @param {Boolean} [options.own=true]\n * Whether to clone own properties only. This is only effective\n * if `keys` is not defined.\n *\n * @returns {Object} - Returns the cloned object.\n */\n clone(obj, options) {\n if (!obj) return {};\n\n if (utils.isArray(options)) {\n options = { keys: options };\n }\n options = utils.extend({\n keys: null,\n own: true\n }, options);\n\n let include,\n cloned = {};\n\n utils.forIn(obj, (value, key) => {\n include = options.keys\n ? options.keys.indexOf(key) >= 0\n : (options.own && obj.hasOwnProperty(key)) || !options.own;\n if (include) {\n if (utils.isObject(value)) {\n cloned[key] = utils.clone(value, options);\n } else {\n cloned[key] = value;\n }\n }\n });\n return cloned;\n },\n\n /**\n * Maps the values of the given object to a schema to re-structure a new\n * object.\n * @memberof utils\n *\n * @param {Object} obj\n * Original object to be mapped.\n * @param {Object} schema\n * Schema to be used to map the object.\n *\n * @returns {Object} - Mapped object.\n */\n mapToSchema(obj, schema) {\n let mapped = {};\n utils.forIn(schema, (value, key) => {\n if (utils.isPlainObject(value)) {\n mapped[key] = utils.mapToSchema(obj, value);\n } else {\n mapped[key] = obj[value];\n }\n });\n return mapped;\n },\n\n // ---------------------------\n // Misc\n // ---------------------------\n\n /**\n * Safely parses the given JSON `String` into an `Object`.\n * The only difference from `JSON.parse()` is that this method does not\n * throw for invalid input. Instead, returns `null`.\n * @memberof utils\n *\n * @param {String} str - JSON string to be parsed\n * @returns {Object|null} - Returns the parsed `Object` or `null` if the\n * input is invalid.\n */\n safeJsonParse(str) {\n let o = null;\n try {\n o = JSON.parse(str);\n } catch (e) {}\n return o;\n },\n\n /**\n * Gets a timestamp that is seconds or milliseconds since midnight,\n * January 1, 1970 UTC.\n * @memberof utils\n *\n * @param {Boolean} [seconds=false]\n * Specifies whether seconds should be returned instead of\n * milliseconds.\n *\n * @returns {Number} - Returns seconds or milliseconds since midnight,\n * January 1, 1970 UTC.\n */\n time(seconds) {\n let ts = Date.now();\n return seconds ? parseInt(ts / 1000, 10) : ts;\n }\n\n};\n\nexport default utils;\n"],"sourceRoot":""}