Answer the question
In order to leave comments, you need to log in
How to connect google map to vue project?
I'm trying to insert a google map into a vue project and using vue2-google-maps
Initially the code and map looks like this:
codesandbox
var url = 'data.php';
gmarkers = [];
var iws = [];
function initialize() {
var content = document.getElementById('iw');
var lat = 39.9995601,
lng = -75.1395161,
latlng = new google.maps.LatLng(lat, lng);
var mapOptions = {
center: new google.maps.LatLng(lat, lng),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var mapCanvas = document.getElementById('map');
var map = new google.maps.Map(mapCanvas, mapOptions);
downloadUrl(url, function(data) {
var j = eval('(' + data.responseText + ')');
var jlength = j.locations.length;
for (var i = 0; i < jlength; i++) {
console.log( parseFloat(j.locations[i].location.lat) );
var x = parseFloat(j.locations[i].location.lat);
var y = parseFloat(j.locations[i].location.lon);
var name = j.locations[i].name;
var adress = j.locations[i].adress;
var lable = j.locations[i].lable;
var prev = j.locations[i].prev;
gmarkers[name] =
createMarker(
new google.maps.LatLng(x, y),
lable
); .....
downloadUrl(url, function(data) {
var j = eval('(' + data.responseText + ')');
var jlength = j.locations.length;
for (var i = 0; i < jlength; i++) {
console.log( parseFloat(j.locations[i].location.lat) );
var x = parseFloat(j.locations[i].location.lat);
var y = parseFloat(j.locations[i].location.lon);
var name = j.locations[i].name;
var adress = j.locations[i].adress;
var lable = j.locations[i].lable;
var prev = j.locations[i].prev; .......
var url = 'data.php';
inside data() {
the function or separately? <script src="https://maps.google.com/maps/api/js?libraries=places®ion=uk&language=en"></script>
?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question