This is a migrated thread and some comments may be shown as answers.

pass a list of address eg addresses As List(Of String)

7 Answers 91 Views
Map
This is a migrated thread and some comments may be shown as answers.
Andre
Top achievements
Rank 1
Andre asked on 08 Jan 2021, 01:19 AM

Hi Guys

I need to pass a list of addresss which i want to display on a bing map similar to 

currently I use the following for a single address string

 Dim request As Telerik.WinControls.UI.Map.Bing.SearchRequest = New SearchRequest()

        request.Query = addresses(0)
        request.SearchOptions.Count = 10
        request.SearchOptions.QueryParse = True

 

what  approach i should use for multiple address??

Ideally I would like to use a data table which lists an  address in each row of the datatable along with some additional data for displaying on a callout (no geo coordinates) and then add a pin for each address onto the map

 Many Thanks

Andre

7 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Jan 2021, 11:09 AM
Hello, Andre,   

The possible solution that I would recommend you for using multiple addresses in RadMap is to iterate the addresses collection and execute a SearchRequest for each one.

Please refer to the following help article demonstrating how to perform a search request and add a pin on the map once the result is returned and the SearchCompleted event is triggered: https://docs.telerik.com/devtools/winforms/controls/map/providers/bingmaps/search   

You can also have a look at our Demo application >> Map >> Bind Map services >> Search example which is quite useful on this topic.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Andre
Top achievements
Rank 1
answered on 09 Jan 2021, 04:22 AM

Thank you for your reply

Unfortunately it wont work given the example you have offered

For index = 0 To addresses.Count - 1
            request.Query = addresses(index)
            request.SearchOptions.QueryParse = True
            bingProvider.SearchAsync(request)
        Next

This will only display the last address

Please also take note that I mentioned I dont have geo-coordinates for each address, I only have the  street address

 

It would appear that the radmap control as implemented cannot  search and display multiple address on a map

This is a serous shortcoming

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Jan 2021, 09:33 AM
Hello, Andre,   

Please have in mind that RadMap wraps the Bing API: https://docs.microsoft.com/en-us/bingmaps/rest-services/locations/?toc=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fbingmaps%2Frest-services%2Ftoc.json&bc=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2FBingMaps%2Fbreadcrumb%2Ftoc.json 

I have prepared a sample project for your reference demonstrating how to search for multiple addresses and add pins for the found results. I believe that it would fit your scenario. Please give the sample project a try and see how it works on your end. 

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Andre
Top achievements
Rank 1
answered on 14 Jan 2021, 03:36 AM

Thanks Very Much

I have gone with querying the bing api diectly and getting the geo coordinates for each address.

Having got those, I iterate through a datable  add each pin according to the row data 

This then allows me to customize the pins 

There is one problem with this approach , and that seems to be one of zoom on the map. I get the attached screen shot issue when doing the following

 If JobListBindingSource IsNot Nothing Then
            Dim allPoints = New Telerik.WinControls.UI.Map.RectangleG(Double.MinValue, Double.MaxValue, Double.MaxValue, Double.MinValue)
            Dim pinsLayer As Telerik.WinControls.UI.MapLayer = New MapLayer("Pins")

            Me.RadMap3.Layers.Add(pinsLayer)
            Dim location As BingMapsRESTToolkit.Location = Nothing
            For Each RV As DataRowView In JobListBindingSource
                location = TryCast(RV("GPS"), BingMapsRESTToolkit.Location)
                If location IsNot Nothing Then
                    Dim point As New Telerik.WinControls.UI.Map.PointG(location.Point.Coordinates(0), location.Point.Coordinates(1))
                    Dim pin As New Telerik.WinControls.UI.MapPin(point)
                    pin.Size = New System.Drawing.Size(20, 40)

                    pin.BackColor = Color.DeepPink

                    pin.ToolTipText = location.Address.FormattedAddress
                    Me.RadMap3.MapElement.Layers("Pins").Add(pin)
                    Dim callout As New MapCallout(pin)
                    callout.Text = RV("StageName").ToString
                    Me.RadMap3.MapElement.Layers("Pins").Add(callout)
                    allPoints.North = Math.Max(allPoints.North, point.Latitude)
                    allPoints.South = Math.Min(allPoints.South, point.Latitude)
                    allPoints.West = Math.Min(allPoints.West, point.Longitude)
                    allPoints.East = Math.Max(allPoints.East, point.Longitude)
                End If
            Next

            RadMap3.MapElement.ZoomLevel = 17
            If JobListBindingSource.Count = 1 AndAlso location IsNot Nothing Then
                Me.RadMap3.BringIntoView(New Telerik.WinControls.UI.Map.PointG(location.Point.Coordinates(0), location.Point.Coordinates(1)))
            ElseIf JobListBindingSource.Count > 1 Then
                Me.RadMap3.MapElement.BringIntoView(allPoints)
                'Me.RadMap3.Zoom(Me.RadMap3.MapElement.ZoomLevel - 1)
            End If
        Else
            Telerik.WinControls.RadMessageBox.Show("No result found for the provided search query!")
        End If

 

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Jan 2021, 11:24 AM
Hello, Andre,  

According to the provided code snippet, it seems that the ZoomLevel property is set to 17 which is a big zoom factor but it is expected to be less than the MaxZoomLevel. However, the screenshot illustrates that the tiles are not successfully loaded. I suppose that they can't be downloaded for some reason, e.g. the search request currently doesn't return a response. Is this behavior observed for other zoom levels, e.g. 5 or 10?

Is this problem reproducible in the previously provided sample project? Could you please specify the exact steps how to reproduce the problem with it? Feel free to modify it in a way to reproduce the experienced issue and get back to me with it so I can investigate the precise case. Thank you in advance. 

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Andre
Top achievements
Rank 1
answered on 14 Jan 2021, 09:31 PM

Thanks

For some reason the mapcontrol doesn't respond to setting zoom inside the code sample I sent.

If i set the zoom level in the calling method it works BUT if the zoom level is 20 or higher (which seems to be some sort of default...even though the zoom level in the properties  time is set to 17 at design) the issue occurs

 

PS There doesn't seem to be any event which traps a zoom event i fthe zoom is done via the on map zoom buttons

I tired the RadMap3.ZoomGesture but it doesn't get hit if I zoom the map via the zoom buttons

 

What am i missing here?

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Jan 2021, 11:16 AM

Hello, Andre, 

Setting the MapElement.ZoomLevel property first and then calling the BringIntoView method is expected to change the zoom level if the point you want to bring into the view doesn't belong to this level. That is why my sample project calls the BringIntoView method first and then the Zoom method with one zoom level less to display properly the last added pins: 
    Private Sub BingProvider_SearchCompleted(sender As Object, e As SearchCompletedEventArgs)
        Dim allPoints As New Telerik.WinControls.UI.Map.RectangleG(Double.MinValue, Double.MaxValue, Double.MaxValue, Double.MinValue)

        For Each location As Telerik.WinControls.UI.Map.Bing.Location In e.Locations
            Dim point As New Telerik.WinControls.UI.Map.PointG(location.Point.Coordinates(0), location.Point.Coordinates(1))
            Dim pin As New MapPin(point)
            pin.Size = New System.Drawing.Size(20, 40)
            pin.BackColor = Color.Red
            pin.ToolTipText = location.Address.FormattedAddress
            Me.RadMap1.MapElement.Layers("Pins").Add(pin)
            allPoints.North = Math.Max(allPoints.North, point.Latitude)
            allPoints.South = Math.Min(allPoints.South, point.Latitude)
            allPoints.West = Math.Min(allPoints.West, point.Longitude)
            allPoints.East = Math.Max(allPoints.East, point.Longitude)
        Next
        If e.Locations.Length > 0 Then

            If e.Locations.Length = 1 Then
                Me.RadMap1.BringIntoView(New Telerik.WinControls.UI.Map.PointG(e.Locations(0).Point.Coordinates(0), e.Locations(0).Point.Coordinates(1)))
            Else
                Me.RadMap1.MapElement.BringIntoView(allPoints)
                Me.RadMap1.Zoom(Me.RadMap1.MapElement.ZoomLevel - 1)
            End If
        Else
            RadMessageBox.Show("No result found for the provided search query!")
        End If 
    End Sub

When setting the ZoomLevel, please make sure that it is valid according to the provider's MaxZoomLevel.

Clicking the MapZoonInButton and MapZoonOutButton buttons are not supposed to be related with the zoom gestures. These buttons trigger the Click event like all other buttons. Please refer to the below code snippet: 
        AddHandler Me.RadMap1.MapElement.NavigationBarElement.ZoomInButton.Click, AddressOf ZoomInButton_Click
        AddHandler Me.RadMap1.MapElement.NavigationBarElement.ZoomOutButton.Click, AddressOf ZoomOutButton_Click
I believe that it would fit your needs.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Map
Asked by
Andre
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Andre
Top achievements
Rank 1
Share this question
or