Skip to content

Instantly share code, notes, and snippets.

@ericwwsun
Created September 16, 2013 15:57
Show Gist options
  • Save ericwwsun/6582606 to your computer and use it in GitHub Desktop.
Save ericwwsun/6582606 to your computer and use it in GitHub Desktop.
[Javascript] Map object for googlemaps
PL.maps = (function(){
var map,
geoData;
var init = function(mapId,options){
var div = document.getElementById(mapId);
map = new google.maps.Map(div, options);
return map;
};
return {
init: init,
panTo : function(address){
var geocoder = new google.maps.Geocoder();
var address = address;
geocoder.geocode({
'address': address,
'partialmatch': true
}, function(results, status){
if (status == 'OK' && results.length > 0) {
geoData = results[0];
console.log(geoData);
map.fitBounds(geoData.geometry.viewport);
} else {
console.log("Error: Adddress lookup failed.");
}
});
},
theGeoData : function(){
return geoData;
},
addingMarker : function(map, lanlng, icon){
var storeMarker = new google.maps.Marker({
position: lanlng,
animation: google.maps.Animation.DROP,
map: map,
icon: icon
});
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment