B4J Question Google maps in B4J

JTmartins

Active Member
Licensed User
Longtime User
Hi everyone.

I've been playing with B4J, and i really love it.

I wonder is someone could give me some clues to a project.

I have a db with lots of coordinates (lat & long) wich I would like to plot the path in google maps.

Is this possible with B4J as is ? Do we need some extra library ?

I've seen the open street project, however, for my region open street seems to be 50% or more incomplete.

I've never used google maps in terms of programing, so I'm a bit in the dark here, although know about the API key, etc, as I've seen all the B4A projects related.

Any help for a start would be welcome.

Thanks
 
You can show a static map with WebView (or ImageView + HttpUtils2).

For example:
Code: Copy
  WebView1.LoadUrl("http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap" & _
       "&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318" & _
       "&markers=color:red%7Clabel:C%7C40.718217,-73.998284&sensor=false")

SS-2014-02-04_08.16.34.png
 
Upvote 0
hum... So the markers would show the different points. The problem is that they were saved every 10 seconds. So that would be..lots of markers.

I was thinking in ploting the path using polylines, that as far as I can see is something that can be done using maps, but havent quite understood how.

The Idea was to create a king of re-player that could read coordinates and plot the path the map does not need to scroll, that can be done by the user. All help would be welcome.
 
Last edited:
Upvote 0
I've just realized that.

I think I found a way...Looks rather stupid, but it may work.

I've tested how to do it with javascript. Ok. It works.

So, If I have a pre-prepared file with all the js and during my program runtinme I generate js lines like

new google.maps.LatLng(37.772323, -122.214897),
new google.maps.LatLng(21.291982, -157.821856),
new google.maps.LatLng(-18.142599, 178.431),
new google.maps.LatLng(-27.46758, 153.027892)
..
..
..

then insert them in the correct place in the pre-prepared file, I would end up with a file with all the coordinates I want.

then I save this file as HTML

Then firing the webview window with this local html file, shoud give me the result I want.

In theory at least... :)
 
Upvote 0
I've just realized that.

I think I found a way...Looks rather stupid, but it may work.

I've tested how to do it with javascript. Ok. It works.

So, If I have a pre-prepared file with all the js and during my program runtinme I generate js lines like

new google.maps.LatLng(37.772323, -122.214897),
new google.maps.LatLng(21.291982, -157.821856),
new google.maps.LatLng(-18.142599, 178.431),
new google.maps.LatLng(-27.46758, 153.027892)
..
..
..

then insert them in the correct place in the pre-prepared file, I would end up with a file with all the coordinates I want.

then I save this file as HTML

Then firing the webview window with this local html file, shoud give me the result I want.

In theory at least... :)

JTmartins, how did this turn out, if I may ask?
 
Upvote 0
HI Andris,

What I did was to generate a KML file for each track..gave a litle work to do the code, but it came out ok.

Then I upload the generated KML file to our server via FTP.

Then I call : http://maps.google.com/maps?q=http://full link to the KML and we get the map with all the markers in a browser window.

I think that in 2015 Google is going to change something in the service, but I have not yet looked into this subject.

José
 
Last edited:
Upvote 0
Thanks Erel, your solution is more than enough for me..
Code: Copy
WebView1.LoadUrl("http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap" & _
       "&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318" & _
       "&markers=color:red%7Clabel:C%7C40.718217,-73.998284&sensor=false")
So I just use stringbuilder library to parse the latlon data, right?
 
Upvote 0
Back
Top