javascript - how to get the map bounds? -


i'm migrating leaflet , if needed map bound used following code:

var b = map.getbounds(); $scope.filtromapa.lat1 = b.getsouth(); $scope.filtromapa.lat2 = b.getnorth(); $scope.filtromapa.lng1 = b.getwest(); $scope.filtromapa.lng2 = b.geteast(); 

those values valid latitude/longitude positions therefore send backend , query position inside area.

how can using openlayers?

for have is:

var b = map.getview().calculateextent(map.getsize()); 

however positions aren't valid latitude/longitude positions.

i'm using openlayers 3.19.1

following answer @ https://gis.stackexchange.com/questions/122250/how-to-get-the-feature-location-in-openlayers-v3 (and assumptions)

var currentextent = map.getview().calculateextent(map.getsize()),     tlpoint = ol.extent.gettopleft( currentextent ),     brpoint = ol.extent.getbottomright( currentextent ),     tlcoords = ol.proj.transform( tlpoint, 'epsg:3857', 'epsg:4326' ),     brcoords = ol.proj.transform( brpoint, 'epsg:3857', 'epsg:4326' ); 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -