@@ -537,6 +537,48 @@ public void run() {
537537 } else {
538538 call .reject ("map not found" );
539539 }
540+
541+ }
542+ });
543+ }
544+
545+ @ PluginMethod ()
546+ public void viewBounds (final PluginCall call ) {
547+ final String mapId = call .getString ("mapId" );
548+ getBridge ().executeOnMainThread (new Runnable () {
549+ @ Override
550+ public void run () {
551+
552+ CustomMapView customMapView = customMapViews .get (mapId );
553+
554+ if (customMapView != null ) {
555+ JSObject result = new JSObject ();
556+ JSObject bounds = new JSObject ();
557+ JSObject farLeft = new JSObject ();
558+ JSObject farRight = new JSObject ();
559+ JSObject nearLeft = new JSObject ();
560+ JSObject nearRight = new JSObject ();
561+
562+ farLeft .put ("latitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().farLeft .latitude );
563+ farLeft .put ("longitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().farLeft .longitude );
564+ farRight .put ("latitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().farRight .latitude );
565+ farRight .put ("longitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().farRight .longitude );
566+ nearLeft .put ("latitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().nearLeft .latitude );
567+ nearLeft .put ("longitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().nearLeft .longitude );
568+ nearRight .put ("latitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().nearRight .latitude );
569+ nearRight .put ("longitude" , customMapView .googleMap .getProjection ().getVisibleRegion ().nearRight .longitude );
570+
571+ bounds .put ("farLeft" ,farLeft );
572+ bounds .put ("farRight" ,farRight );
573+ bounds .put ("nearLeft" ,nearLeft );
574+ bounds .put ("nearRight" ,nearRight );
575+ result .put ("bounds" ,bounds );
576+
577+ call .resolve (result );
578+ } else {
579+ call .reject ("map not found" );
580+ }
581+
540582 }
541583 });
542584 }
0 commit comments