я просто хочу спросить, так как laravel 5.4 удалил метод выборки... что было бы лучшей альтернативой, которую я могу использовать для своего кода. Вот мой код:
@php
$someArray = array();
// Проходим по циклу и помещаем результаты в $someArray;
while ($row = $query->fetch_assoc()) {
array_push($someArray, array(
'title' => $row['school_name'],
'lat' => $row['latitude'],
'lng' => $row['longitude'],
'description' => $row['enrollment_sy_2014_2015']
));
}
// Convert the Array to a JSON String and echo it
$someJSON = json_encode($someArray);
echo $someJSON;
@endphp
так как мне нужны «название», «лат», «длина» и «описание» в качестве переменных для моей карты. Вот код для моей карты: И я надеюсь, что кто-нибудь может помочь :))
function LoadMap() {
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
//Create and open InfoWindow.
var infoWindow = new google.maps.InfoWindow();
for (var i = 0; i < markers.length; i++) {
var data = markers[i];
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});
//Attach click event to the marker.
(function (marker, data) {
google.maps.event.addListener(marker, "click", function (e) {
//Wrap the content inside an HTML DIV in order to set height and width of InfoWindow.
infoWindow.setContent("<div style = 'width:200px;min-height:40px'>" + data.description + "</div>");
infoWindow.open(map, marker);
});
})(marker, data);
}
}