-1

I have the following script and I am trying to write some modular JS to keep things tidy and organised. However when I call:

weatherAPP.searchCity();

in the document.ready I get 'undefined is not a function'.

How can I make the map variable inside 'generateMap' available to 'searchCity'?

1 Answer 1

2

I'm not sure to fully understand your question, but you can attach map to this:

this.map = new google.maps.Map(mapHolder, mapOptions);

instead of

var map = new google.maps.Map(mapHolder, mapOptions);

and so in searchCity

var map = this.map
1
  • it seems to work but now I have the following error: Uncaught TypeError: Cannot read property '_e3' of null
    – Aessandro
    Oct 20, 2014 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.