Fixes for Google Maps (#2652)

This commit is contained in:
David Bomba 2019-02-03 11:51:49 +11:00 committed by GitHub
parent febb465c71
commit 8eaa382604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,19 +6,6 @@
<script src="{{ asset('js/select2.min.js') }}" type="text/javascript"></script>
<link href="{{ asset('css/select2.css') }}" rel="stylesheet" type="text/css"/>
@if ($client->showMap())
<style>
#map {
width: 100%;
height: 200px;
border-width: 1px;
border-style: solid;
border-color: #ddd;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?key={{ env('GOOGLE_MAPS_API_KEY') }}"></script>
@endif
@stop
@ -233,8 +220,14 @@
</div>
@if ($client->showMap())
<div id="map"></div>
<br/>
<iframe
width="100%"
height="200px"
frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?key={{ env('GOOGLE_MAPS_API_KEY') }}&q={!! e("{$client->address1} {$client->address2} {$client->city} {$client->state} {$client->postal_code} " . ($client->country ? $client->country->getName() : '')) !!}" allowfullscreen>
</iframe>
@endif
<ul class="nav nav-tabs nav-justified">
@ -244,15 +237,12 @@
@endif
@if ($hasExpenses)
{!! Form::tab_link('#expenses', trans('texts.expenses')) !!}
@endif
@if ($hasRecurringQuotes)
{!! Form::tab_link('#recurring_quotes', trans('texts.recurring_quotes')) !!}
@endif
@if ($hasQuotes)
{!! Form::tab_link('#quotes', trans('texts.quotes')) !!}
@endif
@if ($hasRecurringInvoices)
{!! Form::tab_link('#recurring_invoices', trans('texts.recurring_invoices')) !!}
{!! Form::tab_link('#recurring_invoices', trans('texts.recurring')) !!}
@endif
{!! Form::tab_link('#invoices', trans('texts.invoices')) !!}
{!! Form::tab_link('#payments', trans('texts.payments')) !!}
@ -323,16 +313,6 @@
])
</div>
@endif
@if ($hasRecurringQuotes)
<div class="tab-pane" id="recurring_quotes">
@include('list', [
'entityType' => ENTITY_RECURRING_QUOTE,
'datatable' => new \App\Ninja\Datatables\RecurringInvoiceDatatable(true, true),
'clientId' => $client->public_id,
'url' => url('api/recurring_quotes/' . $client->public_id),
])
</div>
@endif
<div class="tab-pane" id="invoices">
@include('list', [
@ -469,50 +449,6 @@
})
}
@if ($client->showMap())
function initialize() {
var mapCanvas = document.getElementById('map');
var mapOptions = {
zoom: {{ DEFAULT_MAP_ZOOM }},
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoomControl: true,
};
var map = new google.maps.Map(mapCanvas, mapOptions)
var address = {!! json_encode(e("{$client->address1} {$client->address2} {$client->city} {$client->state} {$client->postal_code} " . ($client->country ? $client->country->getName() : ''))) !!};
geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
var result = results[0];
map.setCenter(result.geometry.location);
var infowindow = new google.maps.InfoWindow(
{ content: '<b>'+result.formatted_address+'</b>',
size: new google.maps.Size(150, 50)
});
var marker = new google.maps.Marker({
position: result.geometry.location,
map: map,
title:address,
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
} else {
$('#map').hide();
}
} else {
$('#map').hide();
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
@endif
</script>
@stop