Created
March 22, 2016 13:12
-
-
Save FWSimon/25ea959b4328d3812f7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const VueGoogleMap = require('vue-google-maps'); | |
module.exports = { | |
components: { | |
'google-map': VueGoogleMap.Map, | |
}, | |
data: function () { | |
return { | |
}; | |
}, | |
props: { | |
center: { | |
type: Boolean, | |
default: false, | |
twoWay: true | |
} | |
}, | |
ready: function () { | |
var langPrefix = $('#langPrefix').val(); //Get the Landcode from the hidden element in main template | |
var mapCoordinates; | |
//We check if the URL is dk or pl and center the map to the right country. | |
switch (langPrefix) { | |
case 'dk': | |
mapCoordinates = new google.maps.LatLng(56.16744, 11.36104); | |
break; | |
case 'pl': | |
mapCoordinates = new google.maps.LatLng(51.1977299, 19.0184122); | |
break; | |
default: | |
mapCoordinates = new google.maps.LatLng(56.16744, 11.36104); | |
break; | |
} | |
this.CreateMap(mapCoordinates); | |
}, | |
methods: { | |
/** | |
* Set center properties. | |
*/ | |
CreateMap: function (mapCoordinates) { | |
console.log('set properties'); | |
var zoom = 7; | |
//Setup map properties | |
var mapProp = { | |
center : mapCoordinates, | |
zoom : zoom, | |
zoomControl : true, | |
mapTypeId : google.maps.MapTypeId.ROADMAP, | |
disableDefaultUI: true | |
}; | |
//Init the map on the page | |
var map = new google.maps.Map(document.getElementById("googleMap"), mapProp); | |
// To close other open windows | |
var prev_infowindow = false; | |
} | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<google-map style="width: 100%; height: 100%; position: absolute; left:0; top:0" :center="{lat: 1.38, lng: 103.8}" :zoom="12"></google-map> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment