Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

183
Vistas
GoogleMaps get center location of current view

I'm using google maps js in my project.PRoject shows locations by marker in googlemaps. I can add marker with some butotn but marker needs lat and long values so i put the locations[0].lat,locations[0].lon,It works fine but not user friendly.

So, what i want to do is make a static marker into the center of the map, when user slides the map , it will still stay in the middle when the user scrolls the map then user clicks the add location button then it adds.

It can also done with add marker in current view center

Current add location code, map and title is global, index comes from document.ready foreach loop

function addLocation(){  
      var myLatlng = new google.maps.LatLng(allMarkers[0].position.lat()+0.20, allMarkers[0].position.lng()+0.20);

                  var marker = new google.maps.Marker({
            position: latlng,
            map: map,
            title: title,
            draggable: true,
            index:index
        });
 
 
        marker.addListener('dragend', handleEvent);
          marker.addListener("click", () => {
            
              
            allMarkers[index].isDeleted='1';
            allMarkers[index].setMap(null);
            

             });
        allMarkers.push(marker);
}
over 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Asistente virtual