添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
打盹的斑马  ·  How to convert HTML ...·  1 月前    · 
胡子拉碴的小蝌蚪  ·  GitHub - ...·  2 周前    · 
刚毅的红金鱼  ·  CAST and CONVERT ...·  2 周前    · 
俊逸的斑马  ·  CONVERT (SQL) | ...·  2 周前    · 
难过的炒饭  ·  【C++教程】2.3 - ...·  2 年前    · 
傻傻的大蒜  ·  jsoncpp 创建数组-掘金·  2 年前    · 
精明的铁链  ·  Java8 中用法优雅的 ...·  2 年前    · 

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