Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8203189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:27:56+00:00 2026-06-07T07:27:56+00:00

The map displays 2 markers, one with geolocation coordinates and the other one with

  • 0

The map displays 2 markers, one with geolocation coordinates and the other one with some random coordinates. I can’t extend the bounds to fit both markers in the map. What’s wrong? thank you in advance.

<!DOCTYPE html>
<html>
  <head>
    <title>Google Maps JavaScript API v3 Example: Map Geolocation</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=yes">
    <meta charset="UTF-8">
    <link href="https://google-developers.appspot.com/maps/documentation/javascript/examples/default.css"
      rel="stylesheet" type="text/css">

    <script type="text/javascript"
        src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>

    <script type="text/javascript">
      var map;

      function initialize() {
        var myOptions = {
          zoom: 18,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById('map_canvas'),
            myOptions);

        // Try HTML5 geolocation
        if(navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(function(position) {
            var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
            var geolocation = new google.maps.Marker({position: pos, map: map, title: 'Your geolocation', });

            var latitude=47.03249;
            var longitude=28.833747;
            var pos2=new google.maps.LatLng(latitude,longitude);
            var geolocation2 = new google.maps.Marker({position: pos2,map: map,title: 'Your geolocation',});

            var pos3=new google.maps.LatLng((position.coords.latitude+latitude)/2,(position.coords.longitude+longitude)/2);
            map.setCenter(pos3);

            bounds.extend(geolocation.getPosition());              
            bounds.extend(geolocation2.getPosition());  

    map.fitBounds(bounds);

            }, 
            function() {handleNoGeolocation(true);});
        } 
        else {handleNoGeolocation(false);
        }

      }

      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
    <div id="map_canvas" style='width:400px; height:400px;'></div>
  </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:27:57+00:00Added an answer on June 7, 2026 at 7:27 am

    your bounds needs to be a google.maps.LatLngBounds object.
    You don’t ever construct it.

    Add (somewhere before you call extend on it):

    var bounds = new google.maps.LatLngBounds();
    

    BTW – you should be getting javascript errors that make this really clear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display different markers on my map. One solution I could find
Currently I have JavaScript that displays markers on a Google map using the Google
I have a map on a page which displays several places with markers and
I have two locations (markers) to display on a google map, one is a
I have an application where I'm using the Google Map API to display markers
I'm writing an application that displays Google Map right after the login screen. The
I have a website that displays a mashup on Google Map. When I try
I have an App that displays thousands of Pin annotations on a google map
Is it possible to detect if the visible map display more than one time
I'm trying to get multiple markers on a Google map using API V3. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.