Initialize Google Map in AngularJS

后端 未结 4 1152
一个人的身影
一个人的身影 2020-12-07 19:17

I am considering migrating from backbonejs to angularjs.

In backbone I am able to initialize a view at which point I create an instance of google map. I can then pa

4条回答
  •  -上瘾入骨i
    2020-12-07 19:54

    This is what I am doing in Backbone to keep the view instead of destroying it. Suppose you have a div with id="container" and your router have the corresponding routes.

    routes: {
        "":"home",
        "map": "showMap"
    },
    
    showMap: function() {
        $("#container").children().detach();
        if(!this.mapView) {
            this.mapView = new MapView(); 
            this.mapView.render();
        }
        $("#container").html(this.mapView.el);
    }
    

提交回复
热议问题