Skip to content

Instantly share code, notes, and snippets.

@stockenberg
Last active November 3, 2018 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stockenberg/4e31ebbf519bf77d033a9cae22310e87 to your computer and use it in GitHub Desktop.
Save stockenberg/4e31ebbf519bf77d033a9cae22310e87 to your computer and use it in GitHub Desktop.
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: { lat: 51.3400481, lng: 12.3720687 }
});
var _loop = function _loop(i) {
var name = _this.companies[i].name + " - H:" + _this.companies[i].histories.length + " S:" + _this.companies[i].students.length;
if (typeof _this.companies[i].adress !== 'undefined') {
$.ajax({
url: 'https://maps.googleapis.com/maps/api/geocode/json',
method: "get",
data: { 'address': _this.companies[i].adress, 'key': 'YOUR_KEY_HERE' }
}).done(function (res) {
var marker = new MarkerWithLabel({
position: new google.maps.LatLng(res.results[0].geometry.location.lat, res.results[0].geometry.location.lng),
map: map,
labelContent: name,
labelAnchor: new google.maps.Point(5, 41),
labelClass: 'labels', // the CSS class for the label
labelStyle: { opacity: 1.0 }
});
});
}
};
for (var i = 0; i < this.companies.length; i++) {
_loop(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment