Skip to content

Instantly share code, notes, and snippets.

@chyld
Last active August 29, 2015 13:57
Show Gist options
  • Save chyld/9520344 to your computer and use it in GitHub Desktop.
Save chyld/9520344 to your computer and use it in GitHub Desktop.
function initMap(lat, lng, zoom){
var mapOptions = {center: new google.maps.LatLng(lat, lng), zoom: zoom, mapTypeId: google.maps.MapTypeId.ROADMAP};
map = new google.maps.Map(document.getElementById('map'), mapOptions);
}
function addMarker(location){
var position = new google.maps.LatLng(location.lat, location.lng);
var marker = new google.maps.Marker({map:map, position:position, title:location.address});
markers.push(marker);
}
function getLocation(){
var geoOptions = {enableHighAccuracy: true, maximumAge: 1000, timeout: 60000};
navigator.geolocation.getCurrentPosition(geoSuccess, geoError, geoOptions);
}
function geoSuccess(location) {
lat = location.coords.latitude;
lng = location.coords.longitude;
$('#sort').show();
}
function geoError() {
console.log('Sorry, no position available.');
}
// =========================
var geocoder = new google.maps.Geocoder();
geocoder.geocode({address:address}, function(results, status){
var name = results[0].formatted_address;
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment