Google api maps and backbone error-Collection of common programming errors
This error compare when try to start function prova in my view:Uncaught TypeError: Cannot read property ‘Element’ of undefined. The error happens at line:var map= new google.maps.Map(document.get.Element.By.Id(‘pagina’),options);
var HomeView = Backbone.View.extend({
template: Handlebars.compile(template),
events: {
"click .log_out":"log_out",
"click .prove":"prove",
'orientationchange' : 'onOrientationChange'
},
initialize: function() {
console.log("inhomeview");
this.render();
},
render: function() {
//var context = JSON.parse(JSON.stringify(this.model));//eliminare
var context=this.model;
var html =this.template(context);
console.log(html);
$('#pagina').empty();
$('#pagina').append(this.$el.html(html));
return this;
},
onOrientationChange: function() {
if(window.orientation == 90 || window.orientation == -90) {
//you are in landscape zone
//do whatever you want to do
}
},
log_out:function(){
console.log("logout");
Parse.User.logOut();
// new AppView;//ERRORE UNDEFINED NOT A FUNCTION
window.location='index.html' ;//METTERE UNA NEW APPVIEW MA DA ERRORE!!!
},
prove:function(){
navigator.geolocation.getCurrentPosition(win);
function win(pos){
console.log("gps");
var el=''+ pos.coords.latitude+'';
el+=''+ pos.coords.longitude+'';
el+=''+ pos.timestamp+'';
$('#pagina').html(el);
var lat=pos.coords.latitude;
var lon=pos.coords.longitude;
var options={
center:new google.maps.LatLng(-34,150),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var html=$('#pagina');
console.log(html);
var map= new google.maps.Map(document.get.Element.By.Id('pagina'),options);// ERROR HERE
};
}
});
return HomeView;
-
This looks incorrect:
document.get.Element.By.Id
I would expect:
document.getElementById
Which would explain the error message:
Uncaught TypeError: Cannot read property ‘Element’ of undefined.
Originally posted 2013-11-10 00:29:47.