Dear all,
I would like to get client location dynamically through google maps api.
Below are my code:
/*Call external api dynamically*/
var script = document.createElement("script");
script.src = "http://www.google.com/jsapi?key=" + api_key + "&callback=loadm";
script.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(script);
/*function */
function loadm() {
google.load("maps", "3", {other_params:"sensor=false", "callback" : defmap});
}
function defmap() {
if(google.loader.ClientLocation){
alert(google.loader.ClientLocation.latitude+" "+google.loader.ClientLocation.longitude};
}
I have tried it, but null values are returned. Is there error in the code? Please advice. Thank you.