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

How to get map corner latlong in OSM. i have many tried to solve it but i did not solve it.

i have use below example.

===================================================

<html> <head> <title>OpenLayers Demo</title> <style type="text/css"> html, body, #basicMap { width: 100%; height: 100%; margin: 0; } </style>

<script src="http://www.openlayers.org/api/OpenLayers.js" type="text/javascript"></script>

<script type="text/javascript">
    function init() {
        var marker_layer = new OpenLayers.Layer.Markers("Markers");

        var map = new OpenLayers.Map("basicMap");
        var mapnik = new OpenLayers.Layer.OSM();
        var fromProjection = new OpenLayers.Projection("EPSG:4326");   // Transform from WGS 1984
        var toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection

        var position1 = new OpenLayers.LonLat(78.9629, 20.5937).transform(fromProjection, toProjection);
        var position2 = new OpenLayers.LonLat(79.2629, 20.9937).transform(fromProjection, toProjection);
        var zoom = 8;

        map.addLayer(mapnik);
        map.setCenter(position1, zoom);


        debugger;

        var bounds = map.getBounds();       //Error : map.getBounds is not a function

        var vv1 = map.getView().calculateExtent();  //Error : map.getView is not a function

    }
</script>

</head> <body onload="init();">

</body> </html>

===================================================

asked 15 Jul '16, 08:30

Jatin%20Patel's gravatar image

Jatin Patel
11557
accept rate: 0%

closed 16 Jul '16, 07:47

scai's gravatar image

scai ♦
33.3k21309459

If possible then write a solution for above query...

Thanks in advance.

(16 Jul '16, 07:13) Jatin Patel

The question has been closed for the following reason "Duplicate Question, see https://help.openstreetmap.org/questions/50696/how-to-get-map-corner-latlong-using-open-layer" by scai 16 Jul '16, 07:47

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:

×2
×1

question asked: 15 Jul '16, 08:30

question was seen: 2,560 times

last updated: 16 Jul '16, 07:47

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