I don't want to use any bundle. I want to get gps location from the DB to the into the google map using Ajax request but got few issue 1. this is the map script in my twig
<script>
function int()
{
var myLatlng = new google.maps.LatLng(49.47143, 11.107489999999984);
var mapOptions = {
zoom: 8,
center: myLatlng
};
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var marker;
$.ajax({
type: "GET",
url: "{{ path('home_page') }}",
data: "addr="+encodeURI("{{ location.address }}, {{ location.contacts }}, {{ location.managerName }}"),
success: function(data) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(data.lat, data.longi),
map: map,
title: 'test'
});
}
});
}
google.maps.event.addDomListener(window, 'load', init);
</script>
this is the controller that is getting the GPS location from the server end
public function indexAction(Request $request) {
$em = $this->getDoctrine()->getEntityManager();
$resultsee=$em->createQuery('select a.lat,a.longi,a.managerName,a.address,a.contacts from AdminBundle:location a'); $entities = $resultsee->getResult();
return new JsonResponse(array('location' => $entities));
}
Finally this is the error I get instead of displaying on the map
{"location":[{"lat":"13.459326003707657","longi":"-16.580506139062436","managerName":"Lamin L Janneh","address":"Banjul","contacts":"3930050"}]}