0

I'm working on a small project with Leaflet, and trying to diagnose why using the map.load event is returning Object [object Object] has no method 'load' (although the load event is firing properly)

When I inspect the variable containing the map object in chrome instead of saying

Object {foo: bar}

it says

e {foo: bar}

What does the e represent? I can provide pictures of the chrome inspector output if that would help.

var map = L.map('map', {maxZoom: 16, minZoom: 4, zoomControl: false})
.setView([46.5675115, 17.468262], 6);
map.load(mapInit());

function mapInit() {
  console.log('Ive loaded');
}
rob-gordon
  • 1,419
  • 3
  • 20
  • 38

1 Answers1

1

load is an event, not a method. You need to use on to attach event listeners:

map.on('load', mapInit);
icktoofay
  • 126,289
  • 21
  • 250
  • 231