Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
pasando variables a la devolución de llamada

Estoy usando la API de Google Maps para crear un rastreador de activos. Necesito pasar la latitud y la longitud a través de la devolución de llamada initMap para que javascript pueda crear el mapa correctamente.

 <html> <head> <title>Add Map</title> <script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script> <link rel="stylesheet" type="text/css" href="./style.css" /> <script type="module" src="./index.js"></script> </head> <body> <h3>My Google Maps Demo</h3> <!--The div element for the map --> <div id="map"></div> <script src="https://maps.googleapis.com/maps/api/js?key=MY_KEY&callback=initMap&v=weekly" defer ></script> </body> </html>

el javascript...

 // Initialize and add the map function initMap() { // The location of Uluru const uluru = { lat: -25.344, lng: 131.031 }; // The map, centered at Uluru const map = new google.maps.Map(document.getElementById("map"), { zoom: 4, center: uluru, }); // The marker, positioned at Uluru const marker = new google.maps.Marker({ position: uluru, map: map, }); } window.initMap = initMap;

y este es mi controlador. Estoy tratando de obtener los datos en GpsMessage desde/addlocation en javascript.

 @Controller public class GpsController { @GetMapping("/greeting") public String greeting(@RequestParam(name="name", required=false, defaultValue="World") String name, Model model) { model.addAttribute("name", name); return "greeting"; } @GetMapping("/map") public String map(@RequestParam(name="name", required=false, defaultValue="World") String name, Model model) { model.addAttribute("name", name); return "map"; } @PostMapping("/addlocation") public boolean addLocation(@RequestBody GpsMessage message) { System.out.println(message.toString()); return DbConnection.writeLocation(message); } @GetMapping("/readLocations") public List<Double> readLocations() { return DbConnection.readLocations(); } }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!