{"id":20631042,"url":"https://github.com/gfarrell/mootoolsgeolocation","last_synced_at":"2025-08-31T16:32:44.083Z","repository":{"id":4694415,"uuid":"5841430","full_name":"gfarrell/MootoolsGeolocation","owner":"gfarrell","description":"HTML5 Geolocation API for Mootools-based applications.","archived":false,"fork":false,"pushed_at":"2012-09-17T13:53:54.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-17T07:09:16.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gfarrell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-17T13:33:09.000Z","updated_at":"2014-03-11T20:00:29.000Z","dependencies_parsed_at":"2022-09-01T04:40:40.034Z","dependency_job_id":null,"html_url":"https://github.com/gfarrell/MootoolsGeolocation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfarrell%2FMootoolsGeolocation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfarrell%2FMootoolsGeolocation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfarrell%2FMootoolsGeolocation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfarrell%2FMootoolsGeolocation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gfarrell","download_url":"https://codeload.github.com/gfarrell/MootoolsGeolocation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242588422,"owners_count":20154203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T14:10:38.089Z","updated_at":"2025-03-08T17:56:58.238Z","avatar_url":"https://github.com/gfarrell.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"HTML5 Geolocation Library\n=========================\n\n## Preamble\n\n#### Authors\n* Gideon Farrell [http://www.gideonfarrell.co.uk](http://www.gideonfarrell.co.uk)\n\n#### Requires\n\n* RequireJS\n* Mootools/Core/Class\n* Mootools/Core/Class/Extras/Events\n\n#### Provides\n\n* Location\n* Extra Number methods\n\n#### License\n\nCopyright (c) 2012 Gideon Farrell [\u003cme@gideonfarrell.co.uk\u003e](mailto:me@gideonfarrell.co.uk)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n## Usage\n\n### Creating a new Location object\n\n\tvar loc = new Location(latitude, longitude)\n\t\n* latitude (*Number*) must be between **-90** and **+90**\n* longitude (*Number*) must be between **-180** and **+180**\n\n### Other factory methods\n\nThe **Location** class comes with some factory methods for creating new **Location**s, namely `newLocationFromArray` and `newFromCurrentLocation`.\n\n\tvar location_array = [lat, lon],\n\t\tloc            = Location.newLocationFromArray(location_array);\n\t\t\nThis creates a new **Location** object from an array of latitude and longitude. Useful when de-serialising data (e.g. from JSON).\n\n\tvar loc = Location.newFromCurrentLocation();\n\t\nThis creates a new **Location** object which then tries to get the current location. An *update* event will be fired when the current location is found.\n\n### Manually setting the location\n\nYou can change the *latitude* and *longitude* of the **Location** instance by accessing its properties directly, e.g.:\n\n\tvar loc = new Location(0,0);\t// Set latitude and longitude to 0,0\n\t\n\t// Setting latitude and longitude directly\n\tloc.latitude  = 53;\n\tloc.longitude = 21;\n\t\nEach time *latitude* or *longitude* is set, an *update* event is fired on the instance. If you need to set both properties, however, you probably do not want two events to be fired, thus a convenience property, *position*, which can be used to set both:\n\n\tloc.position = [53, 21];\n\nThis achieves the same as the above code (without the instantiation, of course) but in one line and with only one event being triggered.\n\n### Finding the distance between locations\n\nTo find the distance between two locations (let's call them `loc_a` and `loc_b`) we have two options: either we can use the class level method `distanceBetweenLocations` or the instance level method `distanceTo`. For example, these two give the same result:\n\n\tLocation.distanceBetweenLocations(loc_a, loc_b);\n\t\n\tloc_a.distanceTo(loc_b);\n\t\n### Tracking the current location\n\nThere are two ways of getting the current location. The first involves a one off call to get the current location from the browser, and the second involved continuously tracking the location. Both methods will trigger *update* events whenever the **Location** instance is updated.\n\nTo get the current location once:\n\n\tvar loc = new Location(0,0); // new Location instance at 0,0\n\tloc.setToCurrent();          // get the current location\n\t\nTo track the location continuously\n\n\tvar loc = new Location(0,0); // new Location instance at 0,0\n\tloc.trackLocation({\n\t\tcontinuous: true\n\t});\n\t\nAnything that interfaces with the browser's Geolocation API is asynchronous, and so the *update* event must be relied on in order to get the current location:\n\n\tvar loc = new Location(0,0);\n\tloc.addEvent('update', function() {\n\t\tvar position = loc.position;\n\t\t// do something …\n\t});\n\t\n\tloc.setToCurrent();\n\n### Serialisation of the **Location** object\n\nFor data storage and transmission, **Location** provides two serialisation methods: `toString` and `toJSON`:\n\n\tvar loc = new Location(53, 21);\n\t\n\tloc.toString();\t\t\t\t\t\t// \"[53,21]\"\n\tloc.toJSON();\t\t\t\t\t\t// [53,21]\n\nWhen retrieved from the serialised format, one should use the factory method `newLocationFromArray`, but the string format must first be parsed by a **JSON** parser to convert it to an array.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgfarrell%2Fmootoolsgeolocation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgfarrell%2Fmootoolsgeolocation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgfarrell%2Fmootoolsgeolocation/lists"}