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

# [closed] How to get boundary points of different zoom levels through getBounds() method of leaftlet API?

 -2 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 © OpenStreetMap contributors, CC-BY-SA, Imagery © CloudMade', 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 ("Center point: " + "
" + e.latlng + "
").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 Kaul 29●3●4●10 accept rate: 0% Frederik Ramm ♦ 82.5k●92●720●1273 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

### Follow this question

By Email:

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

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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,521 times

last updated: 11 Oct '12, 23:30

### Related questions

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