0

在我看来,尝试启动函数 prova 时比较此错误:未捕获的类型错误:无法读取未定义的属性“元素”。错误发生在行: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='<div>'+ pos.coords.latitude+'</div>';
        el+='<div>'+ pos.coords.longitude+'</div>';
        el+='<div>'+ pos.timestamp+'</div>';
        $('#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;
4

1 回答 1

1

这看起来不正确:

document.get.Element.By.Id

我希望:

document.getElementById

这将解释错误消息:

未捕获的类型错误:无法读取未定义的属性“元素”。

于 2013-05-11T21:57:15.130 回答