Merge pull request #6459 from svbergerem/spv-map-fix-console-error
Fix console error for map in SPV
This commit is contained in:
commit
4f23b901e1
2 changed files with 64 additions and 37 deletions
|
|
@ -27,11 +27,11 @@ app.views.SinglePostContent = app.views.Base.extend({
|
|||
},
|
||||
|
||||
map : function(){
|
||||
if (this.$el.find(".mapContainer")){
|
||||
if (this.$(".mapContainer").length < 1){ return; }
|
||||
|
||||
// find and set height of mapContainer to max size of the container
|
||||
// which is necessary to have all necessary tiles prerendered
|
||||
var mapContainer = this.$el.find(".mapContainer");
|
||||
var mapContainer = this.$(".mapContainer");
|
||||
mapContainer.css("height", "200px");
|
||||
|
||||
// get location data and render map
|
||||
|
|
@ -72,7 +72,6 @@ app.views.SinglePostContent = app.views.Base.extend({
|
|||
// put marker on map
|
||||
L.marker(location).addTo(map);
|
||||
return map;
|
||||
}
|
||||
},
|
||||
|
||||
toggleMap: function () {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,34 @@ describe("app.views.SinglePostContent", function() {
|
|||
gon.appConfig = { map: {mapbox: {enabled: true, id: "yourID", accessToken: "yourAccessToken" }}};
|
||||
});
|
||||
|
||||
describe("map", function() {
|
||||
context("with location provided", function() {
|
||||
beforeEach(function(){
|
||||
this.post.set({location : factory.location()});
|
||||
spec.content().html(this.view.render().el);
|
||||
gon.appConfig = { map: {mapbox: {enabled: false }}};
|
||||
});
|
||||
|
||||
it("initializes the leaflet map", function() {
|
||||
spyOn(L, "map").and.callThrough();
|
||||
this.view.map();
|
||||
expect(L.map).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
context("without location provided", function() {
|
||||
beforeEach(function(){
|
||||
spec.content().html(this.view.render().el);
|
||||
});
|
||||
|
||||
it("doesn't initialize the leaflet map", function() {
|
||||
spyOn(L, "map");
|
||||
this.view.map();
|
||||
expect(L.map).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("toggleMap", function() {
|
||||
context("with location provided", function() {
|
||||
beforeEach(function(){
|
||||
|
|
|
|||
Loading…
Reference in a new issue