我在Laravel有两个观点,一个是针对'denuncia'另一个是地图'。在' denuncia'我得到了用户的位置,我想要的是将该值传递给视图' map'。
' denuncia'的代码:
@extends('layouts.master')
@section('content')
<h1>Denuncia</h1>
<div class="table">
<table class="table table-bordered table-striped table-hover">
<thead>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<tr>
<th>#</th><th>CI Denunciante</th><th>Tipo Denuncia</th>
<th>Ubicacion</th><th>Ver Mapa</th><th>Cant.V�ctimas</th>
<th>Estado</th><th>Servicio</th><th>Cant.Rodados</th>
<th>Afectado</th><th>Agresi�n F.</th><th>Menores</th>
<th>Cant.Autores</th><th>Medio</th><th>Sexo</th>
<th>Color-Pelo</th><th>Color-piel</th><th>Color-Ropa</th>
<th>Vestimenta</th><th>Fecha</th>
</tr>
</thead>
<tbody>
{{-- */$x=0;/* --}}
@foreach($denuncia as $item)
{{-- */$x++;/* --}}
<tr>
<td>{{ $item->id_denuncia }}</td>
<td>{{ $item->cuenta->ci }}</td>
<td>{{ $item->tipo->descripcion }}</td>
<td>{{ $item->ubicacion }}</td>
<!--this is where I have to pass the value -->
<td>
<a href="{{ url('/map/' . $item->ubicacion ) }}" class="btn btn-success btn-xs"
title="Ver Mapa">
<span class="glyphicon glyphicon-eye-open" aria-hidden="true"/></a>
</td>
<td>{{ $item->cant_victimas }}</td>
<td>{{ $item->estado_victimas }}</td>
<td>{{ $item->servicio }}</td>
<td>{{ $item->cant_rodados }}</td>
<td>{{ $item->afectado }}</td>
<td>{{ $item->agresion_fisica }}</td>
<td>{{ $item->menores }}</td>
<td>{{ $item->autores_cantidad }}</td>
<td>{{ $item->medio }}</td>
<td>{{ $item->sexo }}</td>
<td>{{ $item->color_pelo }}</td>
<td>{{ $item->color_piel }}</td>
<td>{{ $item->color_ropa }}</td>
<td>{{ $item->vestimenta }}</td>
<td>{{ $item->fecha }}</td>
</tr>
@endforeach
</tbody>
</table>
<div class="pagination"> {!! $denuncia->render() !!} </div>
</div>
@endsection
&#13;
地图代码(我希望从&#39; denuncia&#39;获得价值):
<html>
<head>
<style type="text/css">
html, body { height: 100%; margin: 0; padding: 0; }
#map { height: 100%; }
</style>
</head>
<body>
<div id="map"></div>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 4
});
var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h1 id="firstHeading" class="firstHeading">Uluru</h1>'+
'<div id="bodyContent">'+
'<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +
'sandstone rock formation in the southern part of the '+
'Northern Territory, central Australia. It lies 335 km (208 mi) '+
'south west of the nearest large town, Alice Springs; 450 km '+
'(280 mi) by road. Kata Tjuta and Uluru are the two major '+
'features of the Uluru - Kata Tjuta National Park. Uluru is '+
'sacred to the Pitjantjatjara and Yankunytjatjara, the '+
'Aboriginal people of the area. It has many springs, waterholes, '+
'rock caves and ancient paintings. Uluru is listed as a World '+
'Heritage Site.</p>'+
'<p>Attribution: Uluru, <a href="https://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+
'https://en.wikipedia.org/w/index.php?title=Uluru</a> '+
'(last visited June 22, 2009).</p>'+
'</div>'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var marker = new google.maps.Marker({
position:{lat: -34.397, lng: 150.644},
map: map,
title: 'Location'
});
marker.addListener('click', function() {
infowindow.open(map, marker);
});
var infowindow = new google.maps.InfoWindow({ content : contentString});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?callback=initMap">
</script>
</body>
</html>
&#13;
我的地图控制器中的代码加载索引页面:
public function index()
{
$map = map::paginate(15);
return view('map.index', compact('map'));
}
我希望收到存储在&#39; denuncia&#39;中的位置值。放入谷歌地图提供的上述代码并用标记显示。
提前谢谢!