Skip to content

mgerton/guier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Guier


Guier is a wrapper library for the Google Maps API. Guier specifically targets users who are looking for a more simplified way to work with data Google's API returns when working with reverse-geocoding (returning a human-readable location from coordinates).

Installation and Basic Usage

As with most JavaScript libraries, you'll first want to grab a copy of the library and add it into your page after the Maps API script tag:

<script src="http://www.google.com/jsapi"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="guier.js"></script>

From here, you have two different methods in which you can use Guier to get your location data:

  1. Call Guier's init() method in a basic onload event, explicitly defining the coordinates to use:

    // We start by initializing the Google Maps objects to enforce loose coupling
    var geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.Latlng(41.87885150, -87.63647820000001);
    
    // Now we pass the Geocoder and Latlng objects into Guier's init() method
    Guier.init({
    	geocoder: geocoder,
    	coordinates: latlng
    });
    
    console.log(Guier.get('city'));	// Outputs 'Chicago'
  2. Utilize the HTML5 Geolocation API and initialize Guier within the geolocation object's callback:

    // Checking first for geolocation support of course
    var geolocation = navigator.geolocation ? navigator.geolocation : false;
    if (!!geolocation) {
    	geolocation.getCurrentPosition(function () {
    		// Now we can create the coordinates and initalize Guier
    		var geocoder = new google.maps.Geocoder();
    		var latlng = new google.maps.Latlng(position.coords.latitude, position.coords.longitude);
    
    		Guier.init({
    			geocoder: geocoder,
    			coordinates: latlng
    		});
    	});
    }

FAQs

Q: What's the goal of this library? A: To be a simple, (hopefully) lightweight wrapper library that helps developers with headaches when attempting to work with the returned data from Google's Geocoder object, specifically in the case of reverse geocoding.

Q: Guier? Huh? A: I was searching for a unique name that I could use to make the library stand out. After reading Wikipedia's article on the origins of GPS, I opted to name the library after William Guier since he was an early pioneer in the technology (plus his last name is pretty cool).

About

A wrapper library for the Google Maps API to simplify working with reverse geocode data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors