1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 16:13:20 +01:00
invoiceninja/resources/views/client/partial/map_js.blade.php
David Bomba 1ad857bac9
Vue JS Scaffolding (#2493)
* client ui

* Paddin out client detail view

* Padding out clients

* Padding out clients

* show maps

* Padding out clients

* fixes for migrations

* client padding

* Working on different Client UX

* more client ux

* New Client UI

* Vue Scaffolding
2018-11-07 16:22:36 +11:00

47 lines
1.3 KiB
PHP

<script type="text/javascript">
function initMap() {
var locations = {!! $locations !!}
var maps = [];
for (var i = 0; i < locations.length; i++) {
console.log(locations[i][1]);
var map = new google.maps.Map(document.getElementById('map' + locations[i].id ), {
zoom: 8,
center: {lat: -34.397, lng: 150.644}
});
var geocoder = new google.maps.Geocoder();
var address = locations[i].address1 + ' ' + locations[i].address2+ ' ' + locations[i].city + ' ' + locations[i].state + ' ' + locations[i].postal_code + ' ' + locations[i].country;
geocodeAddress(geocoder, map + locations[i], address);
};
}
initMap();
//google.maps.event.addDomListener(window, 'load', initMap);
function geocodeAddress(geocoder, resultsMap, address) {
geocoder.geocode({'address': address}, function(results, status) {
if (status === 'OK') {
resultsMap.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: resultsMap,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
</script>