@@ -499,11 +499,12 @@ def option_chosen(name, lineEdit):
499
499
lineEdit .setText ("" )
500
500
501
501
e = self ._iface .mapCanvas ().extent ()
502
- lat = e .xMinimum () + (e .yMaximum () - e .xMinimum ()) / 2
503
- sourceCrs = QgsCoordinateReferenceSystem (3857 )
504
- destCrs = QgsCoordinateReferenceSystem (4326 )
502
+ lat = e .yMinimum () + (e .yMaximum () - e .yMinimum ()) / 2
503
+ lon = e .xMinimum () + (e .xMaximum () - e .xMinimum ()) / 2
504
+ sourceCrs = self ._iface .mapCanvas ().mapSettings ().destinationCrs ()
505
+ destCrs = QgsCoordinateReferenceSystem .fromEpsgId (4326 )
505
506
tr = QgsCoordinateTransform (sourceCrs , destCrs , QgsProject .instance ())
506
- middle = tr .transform (QgsPointXY (0 , lat ))
507
+ middle = tr .transform (QgsPointXY (lon , lat ))
507
508
508
509
url = f"https://api.openrouteservice.org/geocode/autocomplete?api_key={ api_key } &text={ lineEdit .text ()} &sources=geonames&focus.point.lat={ middle .y ()} &focus.point.lon={ middle .x ()} "
509
510
request = QgsBlockingNetworkRequest ()
@@ -685,7 +686,7 @@ def _reindex_list_items(self):
685
686
]
686
687
self .routing_fromline_list .clear ()
687
688
self ._clear_annotations ()
688
- crs = QgsCoordinateReferenceSystem ("EPSG:4326" )
689
+ crs = QgsCoordinateReferenceSystem . fromEpsgId ("EPSG:4326" )
689
690
for idx , x in enumerate (items ):
690
691
coords = x .split (":" )[1 ]
691
692
item = f"Point { idx } :{ coords } "
0 commit comments