Created
September 16, 2013 15:57
-
-
Save ericwwsun/6582606 to your computer and use it in GitHub Desktop.
[Javascript] Map object for googlemaps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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