NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I have written this function to find the corner points according to the 3 different zoom levels.
The problem is that for all the 3 zoom levels, the corner points that I get are "same"!!


    function findCorners ()
    {
        var zoomLevel;
        for (zoomLevel = 7; zoomLevel < 10; zoomLevel++)
        {
            map.setView (centerPoint, zoomLevel);

            var corners        = map.getBounds ();

            // Extracting boundary points
            var northEast      = corners.getNorthEast ();
            var southWest      = corners.getSouthWest ();
            var topLeft        = new L.LatLng (southWest.lat, northEast.lng, true);
            var bottomRight    = new L.LatLng (northEast.lat, southWest.lng, true);

            // For boundary line equation
            var topLeftLng     = toFixedd (topLeft.lng);
            var topLeftLat     = toFixedd (topLeft.lat);
            var bottomRightLng = toFixedd (bottomRight.lng);
            var bottomRightLat = toFixedd (bottomRight.lat);

            var stringCat       = "";
            stringCat           = stringCat.concat (toFixedd (centerPoint.lng) + "," + toFixedd (centerPoint.lat) + "," + zoomLevel + "," + topLeftLng + ",", topLeftLat + ",", + bottomRightLng + "," + bottomRightLat + ",");

            // For map downloading.
            // Attach the northEast and southWest corners too to the above formed string. 
            var bottomLeftLng = toFixedd (southWest.lng);
            var bottomLeftLat = toFixedd (southWest.lat);
            var topRightLng   = toFixedd (northEast.lng);
            var topRightLat   = toFixedd (northEast.lat);

            stringCat         = stringCat.concat (bottomLeftLng + "," + bottomLeftLat + "," + topRightLng + "," + topRightLat);

            arrayCorners.push (stringCat);
        }
        map.setView (centerPoint, 13);
    }

The function for selecting center point is here:

        var map;
        var centerPoint;
        var arrayCenterPoints = new Array ();
        var arrayFileNames    = new Array ();
        var arrayCorners      = new Array ();
        var arrayList         = new Array ();

        function displayMapAndClick ()
        {
            map = L.map ('map', 
                    {
                        dragging: true,
                        scrollWheelZoom: true
                    }).setView ([51.505, -0.09], 13, true);

            L.tileLayer('http://{s}.tile.cloudmade.com/24c8d683cff74bffa7f00e59cd858e00/997/256/{z}/{x}/{y}.png', 
                {
                    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.com">CloudMade</a>',
                    maxZoom: 13,
                }).addTo (map);

            selectCenterPoint ();
        }

        function selectCenterPoint ()
        {
            var popup = L.popup();

            function onMapClick (e) 
            {
                popup
                    .setLatLng  (e.latlng)
                    .setContent ("You clicked the map at: " + e.latlng.toString())
                    .openOn      (map);

                    map.panTo (e.latlng);
                    L.marker (e.latlng).addTo (map).bindPopup ("<b>Center point: </b>" + "<br>" + e.latlng + "<br />").openPopup ();
                    centerPoint = e.latlng; 
            }
            map.on ('click', onMapClick);
        }

       function toFixedd (value) 
       {
        var power         = Math.pow (10, 4 || 0);
        var returnValue = String (Math.round (value * power) / power);
        return returnValue;
       }

Am I on the right track?

asked 11 Oct '12, 11:47

Anisha%20Kaul's gravatar image

Anisha Kaul
293410
accept rate: 0%

closed 11 Oct '12, 23:29

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273

Reason of the downvote? Not a mind reader am I. @someoneelse

(11 Oct '12, 12:28) Anisha Kaul

@Frederik Is this off-topic too?

(11 Oct '12, 12:53) Anisha Kaul

The question has been closed for the following reason "This is not an OpenLayers (or Leaflet) support forum, nor a Javascript support forum. Your problem is not OSM related in the least - your problem would be just the same whether you display OSM tiles or Google tiles or whatever. Please stop abusing this forum with questions that have nothing to do with OSM. If you feel unable to judge which specific forum to direct a question to, I recommed http://gis.stackexchange.com/ which is a general place for all GIS-related stuff." by Frederik Ramm 11 Oct '12, 23:29

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×362
×74
×9

question asked: 11 Oct '12, 11:47

question was seen: 6,585 times

last updated: 11 Oct '12, 23:30

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum