I'm needing to return Latidute and Longitude via an address, however I'm getting a type-conversion error on the return latLng line;

My code:

 public MapPoint GetLatLongFromAddress(AddressData address)
            return GetLatLongFromAddress(address);
        private MapPoint GetLatLongFromAddress(string address)
            var locationService = new GoogleLocationService();
            var point = locationService.GetLatLongFromAddress(address);
            var latidute= point.Latidute;
            var longitude = point.Longitude;
            var latLng = new LatLng()
                Latidute = latidute,
                Longitude = longitude
            return latLng;
private MapPoint GetLatLongFromAddress(string address)
   var locationService = new GoogleLocationService();
   return locationService.GetLatLongFromAddress(address);
						

Hi @Robson Amaral ,

It is not possible to implicitly convert type "Google.Type.LatLng to "GoogleMaps.LocationServices.MatPoint".

The error is clear, you can't implicitly convert type "Google.Type.LatLng to "GoogleMaps.LocationServices.MatPoint".

If you want to return a LatLng object, change the return data type as below:

     public LatLng GetLatLongFromAddress(AddressData address)  
         return GetLatLongFromAddress(address);  
     private LatLng GetLatLongFromAddress(string address)  
         var locationService = new GoogleLocationService();  
         var point = locationService.GetLatLongFromAddress(address);  
         var latidute= point.Latidute;  
         var longitude = point.Longitude;  
         var latLng = new LatLng()  
             Latidute = latidute,  
             Longitude = longitude  
         return latLng;  

If you want to return a MatPoint object, in the GetLatLongFromAddress method, you should create a new MatPoint instance and return it:

     public MapPoint GetLatLongFromAddress(AddressData address)  
         return GetLatLongFromAddress(address);  
     private MapPoint GetLatLongFromAddress(string address)  
         var locationService = new GoogleLocationService();  
         var point = locationService.GetLatLongFromAddress(address);  
         var latidute= point.Latidute;  
         var longitude = point.Longitude;  
         var latLng = new MatPoint()  
             Latidute = latidute,  
             Longitude = longitude  
         return latLng;  

If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best regards,
Dillion