1

i create map with google map Api and i get latitude et longitude position marker and i want to passing this values to my blade and use it . how i can do that

function placeMarker(location) {
  if (marker) {
    marker.setPosition(location);
    positionLat = marker.getPosition().lat();
    positionLng = marker.getPosition().lng();

  } else {
    marker = new google.maps.Marker({
      position: location,
      map: map,
      title: 'هنا يقع العقار',
      icon: markerUrl,
    });
    positionLat = marker.getPosition().lat();
    positionLng = marker.getPosition().lng();
  }
  //my variabels 

  console.log(positionLat);
  console.log(positionLng);
}
Boutamente abdessamad
  • 523
  • 2
  • 10
  • 30
  • Create a suitable endpoint in laravel, then use AJAX, as in an HTTP POST request, as in [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) (Q is essentially a duplicate of [this](https://stackoverflow.com/questions/1917576/how-to-pass-javascript-variables-to-php) but it's very outdated) –  Apr 25 '18 at 21:59
  • okey .no solution without ajax ? – Boutamente abdessamad Apr 25 '18 at 22:05
  • 1
    No, unless you're fine with navigating to a new page. In that case you can do `document.location = "index.php?lat=" + positionLat;` and simply read the GET parameter. –  Apr 25 '18 at 22:07

0 Answers0