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(){
|
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
|
// find and set height of mapContainer to max size of the container
|
||||||
// which is necessary to have all necessary tiles prerendered
|
// which is necessary to have all necessary tiles prerendered
|
||||||
var mapContainer = this.$el.find(".mapContainer");
|
var mapContainer = this.$(".mapContainer");
|
||||||
mapContainer.css("height", "200px");
|
mapContainer.css("height", "200px");
|
||||||
|
|
||||||
// get location data and render map
|
// get location data and render map
|
||||||
|
|
@ -72,7 +72,6 @@ app.views.SinglePostContent = app.views.Base.extend({
|
||||||
// put marker on map
|
// put marker on map
|
||||||
L.marker(location).addTo(map);
|
L.marker(location).addTo(map);
|
||||||
return map;
|
return map;
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleMap: function () {
|
toggleMap: function () {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,34 @@ describe("app.views.SinglePostContent", function() {
|
||||||
gon.appConfig = { map: {mapbox: {enabled: true, id: "yourID", accessToken: "yourAccessToken" }}};
|
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() {
|
describe("toggleMap", function() {
|
||||||
context("with location provided", function() {
|
context("with location provided", function() {
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue