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

164
Views
Agregue múltiples marcadores en el mapa de Google usando el método findPlaceFromQuery

Creé un modal emergente que muestra un mapa de Google que muestra un lugar encontrado con el método findPlaceFromQuery. Esto funciona, pero he intentado agregar varios marcadores en el mapa con el mismo método, pero no funciona. Creo que los lugares deben colocarse en algún tipo de matriz para que funcionen correctamente. ¿Tienes alguna idea? Pondré mi código a continuación y una captura de pantalla del mapa.

Imagen del mapa con un marcador

 let map; let service; let infowindow; function initMap() { const england = new google.maps.LatLng(52.3555, 1.1743); infowindow = new google.maps.InfoWindow(); map = new google.maps.Map(document.getElementById("map_canvas"), { center: england, zoom: 20, mapTypeId: 'hybrid' }); var request = { query: "Oliver Bonas", fields: ["name", "geometry"], }; service = new google.maps.places.PlacesService(map); service.findPlaceFromQuery(request, (results, status) => { if (status === google.maps.places.PlacesServiceStatus.OK && results) { for (let i = 0; i < results.length; i++) { createMarker(results[i]); } map.setCenter(results[0].geometry.location); } }); } function createMarker(place) { if (!place.geometry || !place.geometry.location) return; const marker = new google.maps.Marker({ map, position: place.geometry.location, }); google.maps.event.addListener(marker, "click", () => { infowindow.setContent(place.name || ""); infowindow.open(map); }); } $('#mapModal').on('show.bs.modal', function(event) { initMap(); $("#location-map").css("width", "100%"); $("#map_canvas").css("width", "100%"); });
about 4 years ago · Santiago Gelvez
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!