B4J Question [ABMaterial] How to set the page (very noob inside!)

Bokka

Member
Hello, I have a problem with ABMaterial: I had learned the grid basics and it's ok. Now, I have copied the template folder, renamed folder and two files inside it (according to tutorial), and runned my first web page. BUT I can't understand how to remove the various devices emulator from "my site":

View.png



If I want ONLY display the site, how can I do it?

Thanks in advance
 

Bokka

Member
Excuse me, I have another question, but this time is for ABMGoogleMaps.

I have correctly set the map with lat/lon in my project (and yes, I've obtained an API Key from google and inserted it into the project). When I load the page, the map is displayed correctly.

But I would like to change the lat/lon into the map when I press a button, unfortunately that don't appear. My code is the following:

In the ConnectPage sub I have put that code:

B4X:
gm2.InitializeAsPanorama(page, "gm2", 44.8925288, 10.9189963, 1, 300, 45, 0)

And in the Button code I have that code:

B4X:
Sub btn4_Clicked(Target As String)

   lbl1.Text = "This is a test"
   lbl1.Refresh
   
   gm2.SetLocation(44.7640149,10.931203800000048)
   gm2.Refresh
End Sub

With that code the view of the map don't change with the new coordinates, where I'm wrong?

P.s. In the process global I have declared the variable gm2, and when I press the button, the label (lbl1), change the text correctly, so I think the button work correctly
 
Upvote 0

Bokka

Member
Hi Harris, thanks again for the answer.

The map still won't go, I had tried the same code before post my question, but without luck.


With that code the label1 (lbl1) change the text correctly, but the map don't update the view on the page with the new lat/lon

I have declared the map and the api key in the CLASS GLOBALS:

B4X:
Sub Class_Globals

     Dim gm1 As ABMGoogleMap
     Dim btn4 as ABMButton


End Sub

In the Public Sub I have inserted the maps API:

B4X:
Public Sub Initialize
BuildPage     
   page.GoogleMapsAPIExtras="key=MYGIVENKEY=geometry,places"
End Sub

Then, in the ConnectPage I have initializated the map and the button:

B4X:
public Sub ConnectPage() 

gm1.Initialize(page, "gm1", 50.8500, 2.8833, 15, 350, ABM.GOOGLEMAPTYPE_ROADMAP,0)
   gm1.Draggable = True
   gm1.HasMapTypeControl = True
   gm1.HasStreetViewControl = True
   gm1.HasZoomControl = True
   gm1.AddMapType(ABM.GOOGLEMAPTYPE_ROADMAP)
   gm1.AddMapType(ABM.GOOGLEMAPTYPE_TERRAIN)
   gm1.AddMapType(ABM.GOOGLEMAPTYPE_HYBRID)
   gm1.AddMapType(ABM.GOOGLEMAPTYPE_SATELLITE)

   page.Cell(2,2).AddComponent(gm1)

   gm1.Refresh

 
   btn4.Initializefloating(page, "btn4", "mdi-image-palette", "darkred")
   btn4.size = ABM.BUTTONSIZE_LARGE
   page.Cell(2,10).AddComponent(btn4)

End Sub

Finally, at the bottom of the page I have inserted the code for the button:


B4X:
Sub btn4_Clicked(Target As String)
  
   gm1.Initialize(page, "gm1", 44.8925288, 10.9189963, 15, 350, ABM.GOOGLEMAPTYPE_ROADMAP,0)
   gm1.Refresh
  
   lbl1.Text = "CHANGED"
   lbl1.Refresh
          
End Sub
 
Last edited:
Upvote 0

Harris

Expert
Licensed User
Longtime User
DO: page.refresh - at bottom in your connectpage()

Once you fix the btn4_Clicked event, you could just call it in ConnectPage() if you wish...
' btn4_Clicked("")


B4X:
Sub btn4_Clicked(Target As String)
  
   ' gm1.InitializeAsPanorama(page, "gm1", 44.8925288, 10.9189963, 1, 300, 45, 0)
   ' gm1.Refresh

   ' you have already declared and inited your map in connectpage...  get a reference to it...

   Dim gm as ABMGoogleMap  = page.component("gm1")
   gm.SetLocation(44.8925288, 10.9189963)
   
   ' you could even add Markers...  Another way to show map points - and many of them
   ' gm.AddMarker( "mark1" ,  lat,  lon,  ABM.COLOR_RED, nam1&" - at:  "&DateTime.Time(dt)&"   Value:  "&NumberFormat2( sp ,  1 ,  1 , 1, False)&"" , legend)

   gm.refresh


   ' where in the heck is this label declared???  Does it not give you an error that lbl1 is not found??
   lbl1.Text = "CHANGED"
   lbl1.Refresh
  
   ' page.refresh ' may be needed here as well...
     
 
End Sub
 
Upvote 0

Bokka

Member
Thanks again, now everything is work correctly!!!


P.s. I had declared the label, but I have not pasted the code in the forum
 
Upvote 0
Top