Can't access Leaflet map with Backbone.js -


when initialising leaflet map backbone.js can't access exact map anymore.

e.g.:

mapview.map.locate({setview: true, maxzoom: 10}); 

will result in

typeerror: 'undefined' not function (evaluating 'mapview.map.locate({setview: true, maxzoom: 10})')

the map initialized via separate view in dashboard view like:

this.mapview = new mapview();     $(this.$el).find('.content').append(this.mapview.el).find('.map').addclass('full').css({         'height': $(window).height() / 2     }); 

this view looks like:

var mapview = backbone.view.extend({     template: _.template(""),     render: function ()     {         this.$el.html(this.template());          this.map = l.map(this.el).setview([48.00786, 13.17989], 8);          this.map = l.tilelayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {             attribution: 'openstreetmap &copy; mitwirkende der <a href="http://osm.org/copyright">openstreetmap</a>'         }).addto(this.map);          return this;     } }); 

i can access map object console.log'ing it. result looks like:

_animated: true _bgbuffer: htmldivelement _clearbgbuffertimer: 4 _container: htmldivelement _inithookscalled: true _leaflet_events: object _leaflet_id: 20 _limitedupdate: function s() {var a=arguments;return n?(o=!0,void 0):(n=!0,settimeout(function(){n=!1,o&&(s.apply(i,a),o=!1)},e),t.apply(i,a),void 0);} _map: object _tilecontainer: htmldivelement _tileimg: htmlimageelement _tiles: object _tilestoload: 0 _url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" options: object proto: object

but why not able access map afterwards?

thanks!

problem solved. moved whole map thing view , did not separate map view. that's not finest way it's job quite well.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -