I want to add a variable number of location pins on a WebMapViewer.
I can create a number of webmaplocations but the number of addresses may change each time the map is loaded (taking customer visit locations from a database which will change over time).
What is the best way to declare the New webmalocations?
I have the code from the examples but not sure how to dim a variable number of locations.
You could append them to an array declared without specified size (using -1 or nothing on declaration) when a map is loaded. Doing so wouldn’t specify the number of elements in the array and might be what you are looking for.
I have never used arrays before so tried -
Dim Location() As New WebMapLocation
But it gave aType mismatch error - Expect WebMapLocation() but got WebMapLocation
I also tried to redim after that incase Xojo was expecting to see it but still got the same error.
Dim locations() as webmaplocation
Dim loc as new webmaplocation.
Thanks, that stopped the errors but the following code only its the last location on the map:
Dim Locations() As WebMapLocation
Dim loc as new WebMapLocation
locationMap.MapType = 2
LocationMap.Zoom = 9
locations(0).Latitude = 51.3755190
locations(0).Longitude = 0.0167100
locations(0).Title = “Stevenson Heating Ltd”
locations(1).address = “237 Southlands Road, Bromley, BR1 2EG”
locations(1).Title = “A House”
Am I missing something?
BTW I am just testing now and using the example included with Xojo as a reference.
Each time you start a new location, you need to put
Loc = new webmaplocation
Otherwise, they all refer to the same object in memory.