[WIP] Setup of skeleton
This commit is contained in:
22
resources/views/cornford/googlmapper/circle.blade.php
Normal file
22
resources/views/cornford/googlmapper/circle.blade.php
Normal file
@@ -0,0 +1,22 @@
|
||||
var circleCoordinates_{!! $id !!} = (
|
||||
@foreach ($options['coordinates'] as $key => $coordinate)
|
||||
new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!})
|
||||
@endforeach
|
||||
);
|
||||
|
||||
var circle_{!! $id !!} = new google.maps.Circle({
|
||||
strokeColor: '{!! $options['strokeColor'] !!}',
|
||||
strokeOpacity: {!! $options['strokeOpacity'] !!},
|
||||
strokeWeight: {!! $options['strokeWeight'] !!},
|
||||
fillColor: '{!! $options['fillColor'] !!}',
|
||||
fillOpacity: {!! $options['fillOpacity'] !!},
|
||||
center: circleCoordinates_{!! $id !!},
|
||||
radius: {!! $options['radius'] !!},
|
||||
editable: {!! $options['editable'] ? 'true' : 'false' !!}
|
||||
});
|
||||
|
||||
circle_{!! $id !!}.setMap({!! $options['map'] !!});
|
||||
|
||||
shapes.push({
|
||||
'circle_{!! $id !!}': circle_{!! $id !!}
|
||||
});
|
||||
33
resources/views/cornford/googlmapper/javascript.blade.php
Normal file
33
resources/views/cornford/googlmapper/javascript.blade.php
Normal file
@@ -0,0 +1,33 @@
|
||||
@if (!$view->shared('javascript', false))
|
||||
|
||||
@if ($view->share('javascript', true)) @endif
|
||||
|
||||
@if ($options['async'])
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var initialize_items = [];
|
||||
|
||||
function initialize_method() {
|
||||
initialize_items.forEach(function(item) {
|
||||
item.method();
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script async defer type="text/javascript" src="//maps.googleapis.com/maps/api/js?v={!! $options['version'] !!}®ion={!! $options['region'] !!}&language={!! $options['language'] !!}&key={!! $options['key'] !!}&libraries=places&callback=initialize_method"></script>
|
||||
|
||||
@else
|
||||
|
||||
<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?v={!! $options['version'] !!}®ion={!! $options['region'] !!}&language={!! $options['language'] !!}&key={!! $options['key'] !!}&libraries=places"></script>
|
||||
|
||||
@endif
|
||||
|
||||
@if ($options['cluster'])
|
||||
|
||||
<script type="text/javascript" src="//googlemaps.github.io/js-marker-clusterer/src/markerclusterer.js"></script>
|
||||
|
||||
@endif
|
||||
|
||||
@endif
|
||||
112
resources/views/cornford/googlmapper/map.blade.php
Normal file
112
resources/views/cornford/googlmapper/map.blade.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<div id="map-canvas-{!! $id !!}" style="width: 100%; height: 100%; margin: 0; padding: 0; position: relative; overflow: hidden;"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var maps = [];
|
||||
|
||||
function initialize_{!! $id !!}() {
|
||||
var bounds = new google.maps.LatLngBounds();
|
||||
var infowindow = new google.maps.InfoWindow();
|
||||
var position = new google.maps.LatLng({!! $options['latitude'] !!}, {!! $options['longitude'] !!});
|
||||
|
||||
var mapOptions_{!! $id !!} = {
|
||||
@if ($options['center'])
|
||||
center: position,
|
||||
@endif
|
||||
zoom: {!! $options['zoom'] !!},
|
||||
mapTypeId: google.maps.MapTypeId.{!! $options['type'] !!},
|
||||
disableDefaultUI: @if (!$options['ui']) true @else false @endif,
|
||||
scrollwheel: @if ($options['scrollWheelZoom']) true @else false @endif,
|
||||
zoomControl: @if ($options['zoomControl']) true @else false @endif,
|
||||
mapTypeControl: @if ($options['mapTypeControl']) true @else false @endif,
|
||||
scaleControl: @if ($options['scaleControl']) true @else false @endif,
|
||||
streetViewControl: @if ($options['streetViewControl']) true @else false @endif,
|
||||
rotateControl: @if ($options['rotateControl']) true @else false @endif,
|
||||
fullscreenControl: @if ($options['fullscreenControl']) true @else false @endif
|
||||
};
|
||||
|
||||
var map_{!! $id !!} = new google.maps.Map(document.getElementById('map-canvas-{!! $id !!}'), mapOptions_{!! $id !!});
|
||||
map_{!! $id !!}.setTilt({!! $options['tilt'] !!});
|
||||
|
||||
var markers = [];
|
||||
var infowindows = [];
|
||||
var shapes = [];
|
||||
|
||||
@foreach ($options['markers'] as $key => $marker)
|
||||
{!! $marker->render($key, $view) !!}
|
||||
@endforeach
|
||||
|
||||
@foreach ($options['shapes'] as $key => $shape)
|
||||
{!! $shape->render($key, $view) !!}
|
||||
@endforeach
|
||||
|
||||
@if ($options['overlay'] == 'BIKE')
|
||||
var bikeLayer = new google.maps.BicyclingLayer();
|
||||
bikeLayer.setMap(map_{!! $id !!});
|
||||
@endif
|
||||
|
||||
@if ($options['overlay'] == 'TRANSIT')
|
||||
var transitLayer = new google.maps.TransitLayer();
|
||||
transitLayer.setMap(map_{!! $id !!});
|
||||
@endif
|
||||
|
||||
@if ($options['overlay'] == 'TRAFFIC')
|
||||
var trafficLayer = new google.maps.TrafficLayer();
|
||||
trafficLayer.setMap(map_{!! $id !!});
|
||||
@endif
|
||||
|
||||
var idleListener = google.maps.event.addListenerOnce(map_{!! $id !!}, "idle", function () {
|
||||
map_{!! $id !!}.setZoom({!! $options['zoom'] !!});
|
||||
|
||||
@if (!$options['center'])
|
||||
map_{!! $id !!}.fitBounds(bounds);
|
||||
@endif
|
||||
|
||||
@if ($options['locate'])
|
||||
if (typeof navigator !== 'undefined' && navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(function (position) {
|
||||
map_{!! $id !!}.setCenter(new google.maps.LatLng(position.coords.latitude, position.coords.longitude));
|
||||
});
|
||||
}
|
||||
@endif
|
||||
});
|
||||
|
||||
var map = map_{!! $id !!};
|
||||
|
||||
@if (isset($options['eventBeforeLoad']))
|
||||
{!! $options['eventBeforeLoad'] !!}
|
||||
@endif
|
||||
|
||||
@if (isset($options['eventAfterLoad']))
|
||||
google.maps.event.addListenerOnce(map_{!! $id !!}, "tilesloaded", function() {
|
||||
{!! $options['eventAfterLoad'] !!}
|
||||
});
|
||||
@endif
|
||||
|
||||
@if ($options['cluster'])
|
||||
var markerClusterOptions = {
|
||||
imagePath: '{!! $options['clusters']['icon'] !!}',
|
||||
gridSize: {!! $options['clusters']['grid'] !!},
|
||||
maxZoom: @if ($options['clusters']['zoom'] === null) null @else {!! $options['clusters']['zoom'] !!} @endif,
|
||||
averageCenter: @if ($options['clusters']['center'] === true) true @else false @endif,
|
||||
minimumClusterSize: {!! $options['clusters']['size'] !!}
|
||||
};
|
||||
var markerCluster = new MarkerClusterer(map_{!! $id !!}, markers, markerClusterOptions);
|
||||
@endif
|
||||
|
||||
maps.push({
|
||||
key: {!! $id !!},
|
||||
markers: markers,
|
||||
infowindows: infowindows,
|
||||
map: map_{!! $id !!},
|
||||
shapes: shapes
|
||||
});
|
||||
}
|
||||
|
||||
@if (!$options['async'])
|
||||
|
||||
google.maps.event.addDomListener(window, 'load', initialize_{!! $id !!});
|
||||
|
||||
@endif
|
||||
|
||||
</script>
|
||||
19
resources/views/cornford/googlmapper/mapper.blade.php
Normal file
19
resources/views/cornford/googlmapper/mapper.blade.php
Normal file
@@ -0,0 +1,19 @@
|
||||
@include('googlmapper::javascript')
|
||||
|
||||
@foreach ($items as $id => $item)
|
||||
|
||||
{!! $item->render($id, $view) !!}
|
||||
|
||||
@if ($options['async'])
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
initialize_items.push({
|
||||
method: initialize_{!! $id !!}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
133
resources/views/cornford/googlmapper/marker.blade.php
Normal file
133
resources/views/cornford/googlmapper/marker.blade.php
Normal file
@@ -0,0 +1,133 @@
|
||||
@if ($options['place'])
|
||||
|
||||
var service = new google.maps.places.PlacesService({!! $options['map'] !!});
|
||||
var request = {
|
||||
placeId: '{!! $options['place'] !!}'
|
||||
};
|
||||
|
||||
service.getDetails(request, function(placeResult, status) {
|
||||
if (status != google.maps.places.PlacesServiceStatus.OK) {
|
||||
alert('Unable to find the Place details.');
|
||||
return;
|
||||
}
|
||||
|
||||
@endif
|
||||
|
||||
@if ($options['locate'] && $options['marker'])
|
||||
if (typeof navigator !== 'undefined' && navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(function (position) {
|
||||
marker_0.setPosition(new google.maps.LatLng(position.coords.latitude, position.coords.longitude));
|
||||
});
|
||||
}
|
||||
@endif
|
||||
|
||||
var markerPosition_{!! $id !!} = new google.maps.LatLng({!! $options['latitude'] !!}, {!! $options['longitude'] !!});
|
||||
|
||||
var marker_{!! $id !!} = new google.maps.Marker({
|
||||
position: markerPosition_{!! $id !!},
|
||||
@if ($options['place'])
|
||||
place: {
|
||||
placeId: '{!! $options['place'] !!}',
|
||||
location: { lat: {!! $options['latitude'] !!}, lng: {!! $options['longitude'] !!} }
|
||||
},
|
||||
attribution: {
|
||||
source: document.title,
|
||||
webUrl: document.URL
|
||||
},
|
||||
@endif
|
||||
|
||||
@if (isset($options['draggable']) && $options['draggable'] == true)
|
||||
draggable: true,
|
||||
@endif
|
||||
|
||||
title: {!! json_encode((string) $options['title']) !!},
|
||||
label: {!! json_encode($options['label']) !!},
|
||||
animation: @if (empty($options['animation']) || $options['animation'] == 'NONE') '' @else google.maps.Animation.{!! $options['animation'] !!} @endif,
|
||||
@if ($options['symbol'])
|
||||
icon: {
|
||||
path: google.maps.SymbolPath.{!! $options['symbol'] !!},
|
||||
scale: {!! $options['scale'] !!}
|
||||
}
|
||||
@else
|
||||
icon:
|
||||
@if (is_array($options['icon']) && isset($options['icon']['url']))
|
||||
{
|
||||
url: {!! json_encode((string) $options['icon']['url']) !!},
|
||||
|
||||
@if (isset($options['icon']['size']))
|
||||
@if (is_array($options['icon']['size']))
|
||||
scaledSize: new google.maps.Size({!! $options['icon']['size'][0] !!}, {!! $options['icon']['size'][1] !!})
|
||||
@else
|
||||
scaledSize: new google.maps.Size({!! $options['icon']['size'] !!}, {!! $options['icon']['size'] !!})
|
||||
@endif
|
||||
@endif
|
||||
}
|
||||
@else
|
||||
{!! json_encode($options['icon']) !!}
|
||||
@endif
|
||||
@endif
|
||||
});
|
||||
|
||||
bounds.extend(marker_{!! $id !!}.position);
|
||||
|
||||
marker_{!! $id !!}.setMap({!! $options['map'] !!});
|
||||
markers.push(marker_{!! $id !!});
|
||||
|
||||
@if ($options['place'])
|
||||
|
||||
marker_{!! $id !!}.addListener('click', function() {
|
||||
infowindow.setContent('<a href="' + placeResult.website + '">' + placeResult.name + '</a>');
|
||||
infowindow.open({!! $options['map'] !!}, this);
|
||||
});
|
||||
});
|
||||
|
||||
@else
|
||||
|
||||
@if (!empty($options['content']))
|
||||
|
||||
var infowindow_{!! $id !!} = new google.maps.InfoWindow({
|
||||
content: {!! json_encode((string) $options['content']) !!}
|
||||
});
|
||||
|
||||
@if (isset($options['maxWidth']))
|
||||
|
||||
infowindow_{!! $id !!}.setOptions({ maxWidth: {!! $options['maxWidth'] !!} });
|
||||
|
||||
@endif
|
||||
|
||||
@if (isset($options['open']) && $options['open'])
|
||||
|
||||
infowindow_{!! $id !!}.open({!! $options['map'] !!}, marker_{!! $id !!});
|
||||
|
||||
@endif
|
||||
|
||||
google.maps.event.addListener(marker_{!! $id !!}, 'click', function() {
|
||||
|
||||
@if (isset($options['autoClose']) && $options['autoClose'])
|
||||
|
||||
for (var i = 0; i < infowindows.length; i++) {
|
||||
infowindows[i].close();
|
||||
}
|
||||
|
||||
@endif
|
||||
|
||||
infowindow_{!! $id !!}.open({!! $options['map'] !!}, marker_{!! $id !!});
|
||||
});
|
||||
|
||||
infowindows.push(infowindow_{!! $id !!});
|
||||
|
||||
@endif
|
||||
|
||||
@endif
|
||||
|
||||
@foreach (['eventClick', 'eventDblClick', 'eventRightClick', 'eventMouseOver', 'eventMouseDown', 'eventMouseUp', 'eventMouseOut', 'eventDrag', 'eventDragStart', 'eventDragEnd', 'eventDomReady'] as $event)
|
||||
|
||||
@if (isset($options[$event]))
|
||||
|
||||
google.maps.event.addListener(marker_{!! $id !!}, '{!! str_replace('event', '', strtolower($event)) !!}', function (event) {
|
||||
{!! $options[$event] !!}
|
||||
});
|
||||
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
12
resources/views/cornford/googlmapper/overlay.blade.php
Normal file
12
resources/views/cornford/googlmapper/overlay.blade.php
Normal file
@@ -0,0 +1,12 @@
|
||||
var overlayCoordinates_{!! $id !!} = new google.maps.LatLngBounds(
|
||||
@foreach ($options['coordinates'] as $coordinate)
|
||||
new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}),
|
||||
@endforeach
|
||||
);
|
||||
|
||||
overlay_{!! $id !!} = new google.maps.GroundOverlay(
|
||||
'{!! $options['image'] !!}',
|
||||
overlayCoordinates_{!! $id !!}
|
||||
);
|
||||
|
||||
overlay_{!! $id !!}.setMap({!! $options['map'] !!});
|
||||
21
resources/views/cornford/googlmapper/polygon.blade.php
Normal file
21
resources/views/cornford/googlmapper/polygon.blade.php
Normal file
@@ -0,0 +1,21 @@
|
||||
var polygonCoordinates_{!! $id !!} = [
|
||||
@foreach ($options['coordinates'] as $coordinate)
|
||||
new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}),
|
||||
@endforeach
|
||||
];
|
||||
|
||||
var polygon_{!! $id !!} = new google.maps.Polygon({
|
||||
paths: polygonCoordinates_{!! $id !!},
|
||||
strokeColor: '{!! $options['strokeColor'] !!}',
|
||||
strokeOpacity: {!! $options['strokeOpacity'] !!},
|
||||
strokeWeight: {!! $options['strokeWeight'] !!},
|
||||
fillColor: '{!! $options['fillColor'] !!}',
|
||||
fillOpacity: {!! $options['fillOpacity'] !!},
|
||||
editable: {!! $options['editable'] ? 'true' : 'false' !!}
|
||||
});
|
||||
|
||||
polygon_{!! $id !!}.setMap({!! $options['map'] !!});
|
||||
|
||||
shapes.push({
|
||||
'polygon_{!! $id !!}': polygon_{!! $id !!}
|
||||
});
|
||||
20
resources/views/cornford/googlmapper/polyline.blade.php
Normal file
20
resources/views/cornford/googlmapper/polyline.blade.php
Normal file
@@ -0,0 +1,20 @@
|
||||
var polylineCoordinates_{!! $id !!} = [
|
||||
@foreach ($options['coordinates'] as $coordinate)
|
||||
new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!}),
|
||||
@endforeach
|
||||
];
|
||||
|
||||
var polyline_{!! $id !!} = new google.maps.Polyline({
|
||||
path: polylineCoordinates_{!! $id !!},
|
||||
geodesic: {!! $options['strokeColor'] ? 'true' : 'false' !!},
|
||||
strokeColor: '{!! $options['strokeColor'] !!}',
|
||||
strokeOpacity: {!! $options['strokeOpacity'] !!},
|
||||
strokeWeight: {!! $options['strokeWeight'] !!},
|
||||
editable: {!! $options['editable'] ? 'true' : 'false' !!}
|
||||
});
|
||||
|
||||
polyline_{!! $id !!}.setMap({!! $options['map'] !!});
|
||||
|
||||
shapes.push({
|
||||
'polyline_{!! $id !!}': polyline_{!! $id !!}
|
||||
});
|
||||
21
resources/views/cornford/googlmapper/rectangle.blade.php
Normal file
21
resources/views/cornford/googlmapper/rectangle.blade.php
Normal file
@@ -0,0 +1,21 @@
|
||||
var rectangleCoordinates_{!! $id !!} = new google.maps.LatLngBounds(
|
||||
@foreach ($options['coordinates'] as $key => $coordinate)
|
||||
new google.maps.LatLng({!! $coordinate['latitude'] !!}, {!! $coordinate['longitude'] !!})@if (count($options['coordinates']) - 1 > $key), @endif
|
||||
@endforeach
|
||||
);
|
||||
|
||||
var rectangle_{!! $id !!} = new google.maps.Rectangle({
|
||||
strokeColor: '{!! $options['strokeColor'] !!}',
|
||||
strokeOpacity: {!! $options['strokeOpacity'] !!},
|
||||
strokeWeight: {!! $options['strokeWeight'] !!},
|
||||
fillColor: '{!! $options['fillColor'] !!}',
|
||||
fillOpacity: {!! $options['fillOpacity'] !!},
|
||||
bounds: rectangleCoordinates_{!! $id !!},
|
||||
editable: {!! $options['editable'] ? 'true' : 'false' !!}
|
||||
});
|
||||
|
||||
rectangle_{!! $id !!}.setMap({!! $options['map'] !!});
|
||||
|
||||
shapes.push({
|
||||
'rectangle_{!! $id !!}': rectangle_{!! $id !!}
|
||||
});
|
||||
39
resources/views/cornford/googlmapper/streetview.blade.php
Normal file
39
resources/views/cornford/googlmapper/streetview.blade.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<div id="map-canvas-{!! $id !!}" style="height: 100%; margin: 0; padding: 0;"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function initialize_{!! $id !!}() {
|
||||
var bounds = new google.maps.LatLngBounds();
|
||||
var position = new google.maps.LatLng({!! $options['latitude'] !!}, {!! $options['longitude'] !!});
|
||||
|
||||
var mapOptions = {
|
||||
@if ($options['center'])
|
||||
center: position,
|
||||
@endif
|
||||
zoom: {!! $options['zoom'] !!},
|
||||
mapTypeId: google.maps.MapTypeId.{!! $options['type'] !!},
|
||||
disableDefaultUI: @if (!$options['ui']) true @else false @endif
|
||||
};
|
||||
|
||||
var map = new google.maps.Map(document.getElementById('map-canvas-{!! $id !!}'), mapOptions);
|
||||
|
||||
var panoramaOptions = {
|
||||
position: position,
|
||||
pov: {
|
||||
heading: {!! $options['heading'] !!},
|
||||
pitch: {!! $options['pitch'] !!}
|
||||
}
|
||||
};
|
||||
|
||||
var panorama = new google.maps.StreetViewPanorama(document.getElementById('map-canvas-{!! $id !!}'), panoramaOptions);
|
||||
|
||||
map.setStreetView(panorama);
|
||||
}
|
||||
|
||||
@if (!$options['async'])
|
||||
|
||||
google.maps.event.addDomListener(window, 'load', initialize_{!! $id !!});
|
||||
|
||||
@endif
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user