@@ -516,4 +516,45 @@ public void run() {
516516 }
517517 });
518518 }
519+
520+ @ PluginMethod ()
521+ public void viewBounds (final PluginCall call ) {
522+ final String mapId = call .getString ("mapId" );
523+ getBridge ().executeOnMainThread (new Runnable () {
524+ @ Override
525+ public void run () {
526+
527+ CustomMapView customMapView = customMapViews .get (mapId );
528+
529+ if (customMapView != null ) {
530+ JSObject result = new JSObject ();
531+ JSObject bounds = new JSObject ();
532+ JSObject farLeft = new JSObject ();
533+ JSObject farRight = new JSObject ();
534+ JSObject nearLeft = new JSObject ();
535+ JSObject nearRight = new JSObject ();
536+
537+ farLeft .put ("latitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().farLeft .latitude );
538+ farLeft .put ("longitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().farLeft .longitude );
539+ farRight .put ("latitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().farRight .latitude );
540+ farRight .put ("longitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().farRight .longitude );
541+ nearLeft .put ("latitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().nearLeft .latitude );
542+ nearLeft .put ("longitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().nearLeft .longitude );
543+ nearRight .put ("latitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().nearRight .latitude );
544+ nearRight .put ("longitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().nearRight .longitude );
545+
546+ bounds .put ("farLeft" ,farLeft );
547+ bounds .put ("farRight" ,farRight );
548+ bounds .put ("nearLeft" ,nearLeft );
549+ bounds .put ("nearRight" ,nearRight );
550+ result .put ("bounds" ,bounds );
551+
552+ call .resolve (result );
553+ } else {
554+ call .reject ("map not found" );
555+ }
556+
557+ }
558+ });
559+ }
519560}
0 commit comments