{"id":1337,"date":"2022-08-30T15:15:41","date_gmt":"2022-08-30T15:15:41","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/10\/google-api-maps-and-backbone-error-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:15:41","modified_gmt":"2022-08-30T15:15:41","slug":"google-api-maps-and-backbone-error-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/google-api-maps-and-backbone-error-collection-of-common-programming-errors\/","title":{"rendered":"Google api maps and backbone error-Collection of common programming errors"},"content":{"rendered":"<p>This error compare when try to start function prova in my view:Uncaught TypeError: Cannot read property &#8216;Element&#8217; of undefined. The error happens at line:var map= new google.maps.Map(document.get.Element.By.Id(&#8216;pagina&#8217;),options);<\/p>\n<pre><code>        var HomeView = Backbone.View.extend({\n\n  template: Handlebars.compile(template),\n\n events: {\n  \"click .log_out\":\"log_out\",\n  \"click .prove\":\"prove\",\n  'orientationchange' : 'onOrientationChange'\n  },\n\n  initialize: function() {\n\n      console.log(\"inhomeview\");\n\n     this.render();\n\n\n\n  },\n\n\n\n    render: function() {\n      \/\/var context = JSON.parse(JSON.stringify(this.model));\/\/eliminare\n      var context=this.model;\n      var html =this.template(context);\n      console.log(html);\n\n       $('#pagina').empty();\n       $('#pagina').append(this.$el.html(html));\n\n\n      return this;\n    },\n\n\n    onOrientationChange: function() {\n   if(window.orientation == 90 || window.orientation == -90) {\n \/\/you are in landscape zone\n \/\/do whatever you want to do\n        }\n    },\n\n\n\n\n\n\n\n\n\n\n\n\n    log_out:function(){\n        console.log(\"logout\");\n        Parse.User.logOut();\n     \/\/   new AppView;\/\/ERRORE UNDEFINED NOT A FUNCTION\n     window.location='index.html'  ;\/\/METTERE UNA NEW APPVIEW MA DA ERRORE!!!\n    },\n\n    prove:function(){\n    navigator.geolocation.getCurrentPosition(win);\n    function win(pos){\n        console.log(\"gps\");\n        var el=''+ pos.coords.latitude+'';\n        el+=''+ pos.coords.longitude+'';\n        el+=''+ pos.timestamp+'';\n        $('#pagina').html(el);\n\n\n\n    var lat=pos.coords.latitude;\n    var lon=pos.coords.longitude;\n\n    var options={\n\n        center:new google.maps.LatLng(-34,150),\n        mapTypeId: google.maps.MapTypeId.ROADMAP\n\n    };\n\n      var html=$('#pagina');\n      console.log(html);\n    var map= new google.maps.Map(document.get.Element.By.Id('pagina'),options);\/\/ ERROR    HERE       \n\n\n    };\n\n\n\n\n\n    }\n\n\n });\n\n return HomeView;\n<\/code><\/pre>\n<ol>\n<li>\n<p>This looks incorrect:<\/p>\n<pre><code>document.get.Element.By.Id\n<\/code><\/pre>\n<p>I would expect:<\/p>\n<pre><code>document.getElementById\n<\/code><\/pre>\n<p>Which would explain the error message:<\/p>\n<blockquote>\n<p>Uncaught TypeError: Cannot read property &#8216;Element&#8217; of undefined.<\/p>\n<\/blockquote>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-10 00:29:47. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>This error compare when try to start function prova in my view:Uncaught TypeError: Cannot read property &#8216;Element&#8217; of undefined. The error happens at line:var map= new google.maps.Map(document.get.Element.By.Id(&#8216;pagina&#8217;),options); var HomeView = Backbone.View.extend({ template: Handlebars.compile(template), events: { &#8220;click .log_out&#8221;:&#8221;log_out&#8221;, &#8220;click .prove&#8221;:&#8221;prove&#8221;, &#8216;orientationchange&#8217; : &#8216;onOrientationChange&#8217; }, initialize: function() { console.log(&#8220;inhomeview&#8221;); this.render(); }, render: function() { \/\/var context = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1337","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1337"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1337\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}