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 9021893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:21:58+00:00 2026-06-16T05:21:58+00:00

I have a few map markers that are located all over the place and

  • 0

I have a few map markers that are located all over the place and I want to auto zoom to show them all.

The code I have should work fine but sometimes (seems to depend whereabouts the map markers are) it doesn’t always zoom correctly to show the markers.

Here’s a fiddle (with example markers to show the problem): http://jsfiddle.net/amnesia7/9YUVe/embedded/result/ using the following marker locations:

// Add markers to the map for each location
addMarker(1, "Hello 1", [-18,178.333]);
addMarker(2, "Hello 2", [-18.5,180]);
addMarker(3, "Hello 3", [-18.5,-178.333]);

The auto-zoom has gone completely wrong and seems to be zoomed in on the sea somewhere.

Looks to be a bug to me because it seems to depend on whereabouts the map markers are as to whether it zoom correctly or not.


UPDATE

I’ve created, what I hope will be, a simpler version using the HERE developer demo for “Zoom to a set of markers”

http://jsfiddle.net/amnesia7/uhZVz/

You need to zoom the map out to see the markers that should be in view by default.

Thanks

  • 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-16T05:21:59+00:00Added an answer on June 16, 2026 at 5:21 am

    It looks like a bug to me too, and only occurs when markers cluster around the 180th line of longitude.
    Seems that the zoomTo() calculation is incorrect in this case, only taking in to account the last marker since it is on the “wrong” side of the international date line.

    Anyway, getWidth() on the viewport does seem to work, so you could hack in your own zoomTo() function as shown in the kludge below.

    Also note the use of kml=auto&map=js-p2d-dom when loading the library – this uses the DOM implementation rather than the canvas implementation this properly shows markers on both sides of the 180th line of longitude.

    <!DOCTYPE HTML SYSTEM>
    <html>
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <meta http-equiv="X-UA-Compatible" content="IE=7; IE=EmulateIE9" />
    
            <style type="text/css">
    
                html {
                    overflow:hidden;
                }
    
                body {
                    margin: 0;
                    padding: 0;
                    overflow: hidden;
                    width: 100%;
                    height: 100%;
                    position: absolute;
                }
    
                #mapContainer {
                    width:100%;
                    height: 100%;
                    left: 0;
                    top: 0;
                    position: absolute;
                }
    
     </style>
       <script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.3/jsl.js?kml=auto&map=js-p2d-dom"></script>
        </head>
        <body>
            <div id="mapContainer"></div>
    
        <script type="text/javascript">
     /*    Set authentication token and appid
    *    WARNING: this is a demo-only key
    *    please register on http://api.developer.nokia.com/
    *    and obtain your own developer's API key
    */
    nokia.Settings.set("appId", "APP_ID");
    nokia.Settings.set("authenticationToken", "TOKEN");
    
    
    // Get the DOM node to which we will append the map
    var mapContainer = document.getElementById("mapContainer");
    // Create a map inside the map container DOM node
    var map = new nokia.maps.map.Display(mapContainer, {
        // initial center and zoom level of the map
        center: [52.51, 13.4],
        zoomLevel: 13,
        components: [
            // We add the behavior component to allow panning / zooming of the map
            new nokia.maps.map.component.Behavior()
        ]
    });
    
    
    // We create an instance of Container to store markers per city
    var myContainer = new nokia.maps.map.Container();
    
    /* We add all of the city containers to map's object collection so that
     * when we add markers to them they will be rendered onto the map
     */
    map.objects.add(myContainer);
    
    // We create several of marker for a variety of famous landmarks
    var firstMarker = new nokia.maps.map.StandardMarker(
            [-18, 178.333],
            { text: 1 }
        ),
        secondMarker = new nokia.maps.map.StandardMarker(
            [-18.5, 180],
            { text: 2 }
        ),
        thirdMarker = new nokia.maps.map.StandardMarker(
            [-18.5, -178.333],
            { text: 3 }
        );
    
    // Add the newly created landmakers per city to its container
    myContainer.objects.addAll([firstMarker, secondMarker, thirdMarker]);
    
    /* Now we calculate the bounding boxes for every container.
     * A bounding box represents a rectangular area in the geographic coordinate system.
     */
    var myBoundingBox = myContainer.getBoundingBox();
    
    
    zoom = 1;
    map.setCenter(myBoundingBox.getCenter());
    map.setZoomLevel(zoom);
    
    
    while (map.getViewBounds().getWidth() >  myBoundingBox.getWidth())   {
        zoom++;
        map.setZoomLevel(zoom); 
    }
    zoom--
    map.setZoomLevel(zoom--);
    
    </script>
    
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few markers that I retrieve and want to center the map
I have a few simple entities that are stored in a simple code table
I have few questions. First of all does code below violates law of Demeter?
Any idea of WebMaping (Displaying a GeoSpatial Map) using flex 3. I have few
I'm working on an application that generates a large number of Google Map markers
I have a few classes that read from very delicate tables, which is why
I am drawing markers that represent shops on a map. There is a single
I have been trying to get Markers to Cluster on a Google map for
Currently I have few methods that accept GridView object as parameter and the value
I have a few large projects I am working on in my new place

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.