File tree Expand file tree Collapse file tree
src/android/plugin/google/maps Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1743,7 +1743,17 @@ public void onClick(View view) {
17431743 return ;
17441744 }
17451745 }
1746-
1746+
1747+ public static boolean isNumeric (String str )
1748+ {
1749+ for (char c : str .toCharArray ()) {
1750+ if (!Character .isDigit (c )) {
1751+ return false ;
1752+ }
1753+ }
1754+ return true ;
1755+ }
1756+
17471757 @ TargetApi (Build .VERSION_CODES .JELLY_BEAN_MR1 )
17481758 @ Override
17491759 public View getInfoContents (Marker marker ) {
@@ -1775,6 +1785,30 @@ public View getInfoContents(Marker marker) {
17751785 windowLayer .setOrientation (LinearLayout .VERTICAL );
17761786 LayoutParams layoutParams = new LayoutParams (LayoutParams .WRAP_CONTENT , LayoutParams .WRAP_CONTENT );
17771787 layoutParams .gravity = Gravity .BOTTOM | Gravity .CENTER ;
1788+
1789+ if (styles != null ) {
1790+ try {
1791+ String widthString = styles .getString ("width" );
1792+ Integer width = 0 ;
1793+
1794+ if (widthString .endsWith ("%" )) {
1795+ double widthDouble = Double .parseDouble (widthString .replace ("%" , "" ));
1796+
1797+ width = (int )((double )mapView .getWidth () * (widthDouble / 100 ));
1798+ } else if (isNumeric (widthString )) {
1799+ width = (int )Double .parseDouble (widthString );
1800+
1801+ if (width <= 1 ) { // for percentage values (e.g. 0.5 = 50%).
1802+ width = mapView .getWidth () * width ;
1803+ }
1804+ }
1805+
1806+ if (width > 0 ) {
1807+ layoutParams .width = width ;
1808+ }
1809+ } catch (Exception e ) {}
1810+ }
1811+
17781812 windowLayer .setLayoutParams (layoutParams );
17791813
17801814 //----------------------------------------
You can’t perform that action at this time.
0 commit comments