Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

151
Visualizações
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);
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda