locked
Can I use Latitude and Longitude instead of Address for Bing Mapping? RRS feed

  • Question

  • For purposes of my application, addresses arent as helpful as Lat and Long coordinates, given that the locations I am working with are sometimes off road, not really assigned an actual address. Is it possible to use Lat/Long instead of addresses?  If so:

    1. When setting up my Table, would I simply have it set up as:

    Latitude             String or Decimel

    Longitude          String or Decimel

    2. What is done with the Mapping code?  Currently I see this:

        Public Class MapScreen
    
            Private Sub FullAddress_Changed()
                Me.DisplayName = "Map of " & Me.FullAddress
            End Sub
    
            Private Sub MapScreen_InitializeDataWorkspace(saveChangesTo As List(Of IDataService))
                'Get the city and long name of the state
                Dim mapAddress = MyAddressHelper.ParseAddress(Me.FullAddress)
    
                'We need to send these parameters to the CrimeData query
                If mapAddress.City <> "" Then Me.City = mapAddress.City
                If mapAddress.State <> "" Then Me.State = mapAddress.State
            End Sub
    
        End Class
    
    
    End Namespace



    Monday, December 9, 2013 4:53 PM

Answers

  • Could it be as easy as adding a Latitude and Longitude field, and in the script, replace address, city, state with the coordinates?

    I admire your optimism.  To perform these functions in the HTML Client, you'll need to familiarize yourself with the Bing Map API for JavaScript.  Have a look at the Location Class Properties example and the AJAX Spatial Data Query examples for starters.
    • Marked as answer by Angie Xu Friday, December 20, 2013 7:29 AM
    Wednesday, December 11, 2013 6:15 AM

All replies

  • Hi chuckj

    In LightSwitch HTML Client, we can add mapping functionality by using a Bing map control, and add the script references block.

    <script type="text/javascript" src="Scripts/lightswitch.bing-maps.js" charset="utf-8"></script>

    Here is the reference for you,

    Creating a LightSwitch Client for Mobile Users (Map customer's address )

    Regards

    Angie

                   


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 10, 2013 7:00 AM
  • Thank you for the reply. I'm new to Lightswitch. Currently, I've been using the Contoso Construction sample to learn and customize my app. Basically, I've changed Customers to Sites ( purpose of application is for Planned/Preventive Maintenance of 30 or so communication sites). Half of the sites are off road, so no exact address. Basically, these sites are all that will be mapped. I simply was hoping instead of using the Address I could use a Lat Long, and clicking on the show map button would show the location with pin using the coordinates and not an address.

    Knowing that, can I still try to use a Java script to do this? Could it be as easy as adding a Latitude and Longitude field, and in the script, replace address, city, state with the coordinates?

    Tuesday, December 10, 2013 12:17 PM
  • Could it be as easy as adding a Latitude and Longitude field, and in the script, replace address, city, state with the coordinates?

    I admire your optimism.  To perform these functions in the HTML Client, you'll need to familiarize yourself with the Bing Map API for JavaScript.  Have a look at the Location Class Properties example and the AJAX Spatial Data Query examples for starters.
    • Marked as answer by Angie Xu Friday, December 20, 2013 7:29 AM
    Wednesday, December 11, 2013 6:15 AM
  • Yes, if you make a string that contains latitude and longitude separated by a comma, you can bind the Bing Maps Control to that string and it will display the correct result.

    For instance, I created a Coordinates computed property on an entity and bound the Map Control to that. If we don't have Latitude and Longitude it falls back to Postcode.

    Private Sub Coordinates_Compute(ByRef result As String)
     
        If Latitude.HasValue AndAlso Longitude.HasValue Then
            result = Latitude.ToString & ", " & Longitude.ToString
        ElseIf Not String.IsNullOrWhiteSpace(Postcode) Then
            result = Postcode
        End If
     
    End Sub


    Simon Jones
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.

    Wednesday, September 24, 2014 10:07 AM