strange issue with javascript.Asset mootools-Collection of common programming errors
Hi there dear Collegue,
I’ve a strange issue with the Javascript.asset method in mootools. i’ve the following source:
window.addEvent('domready', function(){
var g = new geo();
});
var geo = new Class({
initialize: function(){
var out = $("out");
if (!navigator.geolocation){
out.set("html","
Geolocation is not supported by your browser
");
return;
}
this.loadGoogleApi();
},
loadGoogleApi:function(){
var myScriptB = Asset.javascript('https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', {
id: 'myScript',
onLoad: function(){
console.log(myScriptB);
}
});
},
findCity: function(position){
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
var geoCoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(latitude,longitude);
geoCoder.geocode({'latLng': latlng}, function(results, status){
this.parseTemplate(results, status);
}.bind(this));
},
parseTemplate: function(results, status){
var adressResult = results[19].formatted_address;
var sp = adressResult.split(",");
var adress = sp[0];
console.log(adress);
},
getLocation: function(){
navigator.geolocation.getCurrentPosition(function(response){
this.findCity(response);
}.bind(this),null);
}
});
When i run this code in my browser (Chrome) i get the following error: Uncaught ReferenceError: Asset is not defined..
when i add the javascript in my plain html text in the section it will work. So the only reason i can come with is that the Asset method isnt working properly.
Can anybody here please help me because.. i’m working on this issue now for some hours and just can’t figure out what the issue is.
thanks in Advance.