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

152
Views
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
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!