Android Question Creating path on map

microbox

Active Member
Licensed User
Longtime User
Hello everyone, I'm trying to make an app that logs the latitude and longitude into a table sent by sms.
The following code for testing has only 2 points location...
B4X:
url = "http://maps.googleapis.com/maps/api/staticmap?center=%2011.232887,125.002113&markers=11.232887,125.002123|11.233897,125.002219&zoom=16&size=600x300&path=color:0x000fff|weight:5|11.232887,125.002123|11.233897,125.002219&key=AIzaSyBYVvwxxy--xxxxxxxxxxxxxxxx"
WebView1.LoadUrl(url)
My question would be how do I convert all points into array. And please do suggest if there is a better way to do this.

Thanks in advance,
microbox
 
Last edited:

microbox

Active Member
Licensed User
Longtime User
I found the "MapView Overlay Example" by warwound fits to my purpose app in mind. How can I add multiple points to create path?
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Note that you can use either the GoogleMaps or the OSMDroid library to display a path on a map.
Each has it's advantages and disadvantages.

This is the reference for the OSMDroid PathOverlay:
PathOverlay
Fields:
  • FILL As Style
    Geometry and text drawn with this style will be filled, ignoring all stroke-related settings in the paint.
  • FILL_AND_STROKE As Style
    Geometry and text drawn with this style will be both filled and stroked at the same time, respecting the stroke-related fields on the paint.
  • STROKE As Style
    Geometry and text drawn with this style will be stroked, respecting the stroke-related fields on the paint.
Methods:
  • AddGreatCircle (StartPoint As GeoPoint, EndPoint As GeoPoint, NumberOfPoints As Int)
    Add NumberOfPoints points to the path to create a great circle path from StartPoint to EndPoint.
  • AddPoint (Latitude As Double, Longitude As Double)
    Add a Point to the path using Latitude and Longitude.
  • AddPoint2 (aLocation As Location)
    Add a Point to the path using a Location object.
  • AddPoint3 (aGeoPoint As GeoPoint)
    Add a Point to the path using a GeoPoint object
  • AddPoints (GeoPoints As List)
    Add a List of GeoPoints to the path.
  • ClearPath
    Clear all points from the path.
  • GetAllPoints As List
    Get a List of all GeoPoints in the path.
  • GetBoundingBox As BoundingBoxE6Wrapper
    Get a BoundingBox which represents the area that is covered by the path.
  • GetNumberOfPoints As Int
    Get the total number of points added to the path.
  • Initialize (aMapView As MapView, PathColor As Int)
    Initialize the PathOverlay and set the PathColor
  • IsInitialized As Boolean
Properties:
  • Alpha As Int
    Get or Set the Alpha transparency of the path.
    Values of 0 to 255 are valid.
    Default value is 255 fully opaque.
  • Color As Int
    Get or Set the color of the path.
  • PathStyle As Style [write only]
    Set the path style used to draw the path.
    Valid values are:
    PathOverlay.FILL
    PathOverlay.FILL_AND_STROKE
    PathOverlay.STROKE

    Default value is PathOverlay.STROKE
  • StrokeWidth As Float
    Get or Set the stroke width used to draw the path.
    Default stroke width is 2 pixels.

Dim and Initialize a PathOverlay.
Use it's AddPoint method to add your points.

Then use the MapView AddOverlay method to add the PathOverlay to the map.

Martin.
 
Upvote 0

microbox

Active Member
Licensed User
Longtime User
Hi...Thanks very much to warwound's library I got it working. Now I can continue working with the app.
But I have another question in mind, is it possible to display multiple icon(person icon) when receiving from multiple sources of GPS? Sorry if I'm still new to this...can anyone give an idea how can it be done?

Again thank you in advance and more power to this forum..
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
You mention the person icon so it may be that you're displaying the user location using the SimpleLocationOverlay?
I've not tested but would imagine that you can add multiple instances of a SimpleLocationOverlay to a MapView.

The more 'traditional' method to display more than one Marker on a MapView is to use an Overlay such as the MarkersOverlay.
This will enable you to detect click and long click events on each Marker and also allow you to use custom icons for each Marker.

Martin.
 
Upvote 0
Top