0byt3m1n1
Path:
/
var
/
lib
/
vz
/
www
/
clients
/
client6
/
web11
/
web
/
wp-content
/
plugins
/
wp-google-maps
/
docs
/
[
Home
]
File: latlng.js.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: latlng.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: latlng.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>/** * @namespace WPGMZA * @module LatLng * @requires WPGMZA */ (function($) { /** * Constructor * @param mixed A latLng literal, or latitude * @param mixed The latitude, where arg is a longitude */ WPGMZA.LatLng = function(arg, lng) { this._lat = 0; this._lng = 0; if(arguments.length == 0) return; if(arguments.length == 1) { if(typeof arg != "object" || !("lat" in arg && "lng" in arg)) throw new Error("Argument must be a LatLng literal"); this.lat = arg.lat; this.lng = arg.lng; } else { this.lat = arg; this.lng = lng; } } WPGMZA.LatLng.isValid = function(obj) { if(typeof obj != "object") return false; if(!("lat" in obj && "lng" in obj)) return false; return true; } Object.defineProperty(WPGMZA.LatLng.prototype, "lat", { get: function() { return this._lat; }, set: function(val) { if(!$.isNumeric(val)) throw new Error("Latitude must be numeric"); this._lat = parseFloat( val ); } }); Object.defineProperty(WPGMZA.LatLng.prototype, "lng", { get: function() { return this._lng; }, set: function(val) { if(!$.isNumeric(val)) throw new Error("Longitude must be numeric"); this._lng = parseFloat( val ); } }); WPGMZA.LatLng.prototype.toString = function() { return this._lat + ", " + this._lng; } WPGMZA.LatLng.prototype.toGoogleLatLng = function() { return new google.maps.LatLng({ lat: this.lat, lng: this.lng }); } /** * @function moveByDistance * @summary Moves this latLng by the specified kilometers along the given heading * @return void * With many thanks to Hu Kenneth - https://gis.stackexchange.com/questions/234473/get-a-lonlat-point-by-distance-or-between-2-lonlat-points */ WPGMZA.LatLng.prototype.moveByDistance = function(kilometers, heading) { var radius = 6371; var delta = parseFloat(kilometers) / radius; var theta = parseFloat(heading) / 180 * Math.PI; var phi1 = this.lat / 180 * Math.PI; var lambda1 = this.lng / 180 * Math.PI; var sinPhi1 = Math.sin(phi1), cosPhi1 = Math.cos(phi1); var sinDelta = Math.sin(delta), cosDelta = Math.cos(delta); var sinTheta = Math.sin(theta), cosTheta = Math.cos(theta); var sinPhi2 = sinPhi1 * cosDelta + cosPhi1 * sinDelta * cosTheta; var phi2 = Math.asin(sinPhi2); var y = sinTheta * sinDelta * cosPhi1; var x = cosDelta - sinPhi1 * sinPhi2; var lambda2 = lambda1 + Math.atan2(y, x); this.lat = phi2 * 180 / Math.PI; this.lng = lambda2 * 180 / Math.PI; } })(jQuery);</code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Circle.html">Circle</a></li><li><a href="module-Distance.html">Distance</a></li><li><a href="module-Event.html">Event</a></li><li><a href="module-EventDispatcher.html">EventDispatcher</a></li><li><a href="module-FriendlyError.html">FriendlyError</a></li><li><a href="module-Geocoder.html">Geocoder</a></li><li><a href="module-GoogleCircle.html">GoogleCircle</a></li><li><a href="module-GoogleGeocoder.html">GoogleGeocoder</a></li><li><a href="module-GoogleInfoWindow.html">GoogleInfoWindow</a></li><li><a href="module-GoogleMap.html">GoogleMap</a></li><li><a href="module-GoogleMarker.html">GoogleMarker</a></li><li><a href="module-GoogleModernStoreLocator.html">GoogleModernStoreLocator</a></li><li><a href="module-GoogleModernStoreLocatorCircle.html">GoogleModernStoreLocatorCircle</a></li><li><a href="module-GooglePolygon.html">GooglePolygon</a></li><li><a href="module-GooglePolyline.html">GooglePolyline</a></li><li><a href="module-GoogleVertexContextMenu.html">GoogleVertexContextMenu</a></li><li><a href="module-InfoWindow.html">InfoWindow</a></li><li><a href="module-LatLng.html">LatLng</a></li><li><a href="module-LatLngBounds.html">LatLngBounds</a></li><li><a href="module-Map.html">Map</a></li><li><a href="module-MapObject.html">MapObject</a></li><li><a href="module-MapsEngineDialog.html">MapsEngineDialog</a></li><li><a href="module-MapSettings.html">MapSettings</a></li><li><a href="module-Marker.html">Marker</a></li><li><a href="module-ModernStoreLocator.html">ModernStoreLocator</a></li><li><a href="module-ModernStoreLocatorCircle.html">ModernStoreLocatorCircle</a></li><li><a href="module-OLCircle.html">OLCircle</a></li><li><a href="module-OLGeocoder.html">OLGeocoder</a></li><li><a href="module-OLInfoWindow.html">OLInfoWindow</a></li><li><a href="module-OLMap.html">OLMap</a></li><li><a href="module-OLMarker.html">OLMarker</a></li><li><a href="module-OLModernStoreLocator.html">OLModernStoreLocator</a></li><li><a href="module-OLModernStoreLocatorCircle.html">OLModernStoreLocatorCircle</a></li><li><a href="module-OLPolygon.html">OLPolygon</a></li><li><a href="module-OLPolyline.html">OLPolyline</a></li><li><a href="module-Polygon.html">Polygon</a></li><li><a href="module-Polyline.html">Polyline</a></li><li><a href="module-WPGMZA.html">WPGMZA</a></li></ul><h3>Classes</h3><ul><li><a href="module-Circle-Circle.html">Circle</a></li><li><a href="module-ModernStoreLocatorCircle-WPGMZA.ModernStoreLocatorCircle.html">ModernStoreLocatorCircle</a></li><li><a href="module-OLGeocoder-OLGeocoder.html">OLGeocoder</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Wed May 16 2018 13:18:38 GMT+0100 (GMT Daylight Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>