Page 1 of 1

Gmap boundaries

Posted: Sun Apr 19, 2015 9:53 pm
by Xavier

Dear all,

I am displaying a google map (easily with your drag & drop Gmap).
Is there any way to obtain the boundaries of the map ?

Thank you in advance
Best regards
Xavier


Gmap boundaries

Posted: Mon Apr 20, 2015 5:32 am
by Evgene Karachevtsev

Hello Xavier,

Could you please clarify do you want to get a border around the component or you want to get the boundaries of displayed area of the map?


Gmap boundaries

Posted: Mon Apr 20, 2015 6:32 am
by Xavier

Hi Evgene,

Sorry for the lack of precision.
I would like to get the boundaries of the displayed area of the map (in term of latitude & longitude, if possible).

Thanks in advance
Kind regards
Xavier


Gmap boundaries

Posted: Mon Apr 20, 2015 7:29 am
by Bruce Stuart

Xavier,

The google reference is here:

https://developers.google.com/maps/do...

The documentation for that method specifically is here:
Image

Example code to get it...
var omap = Appery("google_map").options.mapElement.gmap('get', 'map');
var obounds = omap.getBounds();
// what comes back is a latLang BOUNDS object .... so...the NE corner is:
var oNElatlng = obounds.getNorthEast();
// the SE corner is
var oSElatlng = obounds.getSouthWest();
// and to get the lat - or long of either object
var nNELat = oNElatlng.lat();
var nNELng = oNElatlng.lng();

Best,

Bruce


Gmap boundaries

Posted: Mon Apr 20, 2015 12:58 pm
by Xavier

Dear Bruce,

Thank you for your fast answer !!
I obtained errors and I had to add an extra line of code.

Here is may code:
#####################################
Appery("googlemap_57").options.mapElement.bind('init',function(evt, map) {

var omap = Appery("googlemap_57").options.mapElement.gmap('get', 'map');
var obounds = omap.getBounds();

var oNElatlng = obounds.getNorthEast();
Map_right = oNElatlng.lat();
Map_up = oNElatlng.lng();

var oSOlatlng = obounds.getSouthWest();
Map_left=oSOlatlng.lat();
Map_bottom=oSOlatlng.lng();

});
#####################################
Without the "Appery("googlemap_57").options.mapElement.bind('init',function(evt, map)" part, I obtain the following error and the screen does not load (on web tester:
TypeError: obounds is undefined

Kind regard
Xavier