Reputation:
I am using [this][1] tutorial to create a Google Map and now I want to make a GET request with Axios:
axios.get("http://localhost:8080/mapjson").then(function(response) { })
to use the data of my json file in the map (coordinates, polylines etc).
The problem is that everything inside the axios function is not defined! For example I get the error:
TypeError: Cannot read property 'map' of undefined at eval
Is there any way to use this Google Map code inside my Axios function? I need to pass latitude, longitude and a date/time object.
Upvotes: 0
Views: 960
Reputation: 4258
The line const map = new google.maps.Map(element, options);
creates a map
variable that is local to the mounted
hook. If you want to access map
in another function of the component, add it in the data
property and use this.map
instead.
Upvotes: 1