Map initiation from Atlantic Ocean

I am facing issue in changing the initial coordinates of map from (0,0) to any other coordinates, before going to the map screen. So that map will start from the desired coordinates , not from (0,0).

Replies

We really can't help you with this unless you post some code or tell us what you're actually doing.

This is the code snippet for the map that I am using: Map( coordinateRegion: $locationVM.region, interactionModes: MapInteractionModes.all, showsUserLocation: true, userTrackingMode: nil, annotationItems: locationVM.cityLocationCoordinates, annotationContent: { location in MapAnnotation( coordinate: location.coordinate, content: { StoreMapPinView(storeName:location.name, locationVM:locationVM) .scaleEffect("(location.coordinate.latitude)" == locationVM.clickedStore?.latitude /locationVM.storeList?[locationVM.visibleStoreIndex].latitude ?? ""/ && "(location.coordinate.longitude)" == /locationVM.storeList?[locationVM.visibleStoreIndex].longitude ?? ""/locationVM.clickedStore?.longitude ? 1 : 0.5) .onTapGesture { locationVM.setVisibleStoreIndex(isScrollList: true, tappedLocation: location) proxy.scrollTo(locationVM.visibleStoreIndex, anchor: .top) } // setMapPin(coordinate: location.coordinate) } ) } ) .animation((isAppOpening ? .none : .linear), value: locationVM.region) .accentColor(Color.blue) and the function that using for region update on appearing the screen: @Published var clickedStore: StoreListModel? { didSet { updateStoreMapRegion(storeLocation:clickedStore) } } private func updateStoreMapRegion(storeLocation: StoreListModel?) { if let latitude = storeLocation?.latitude, let longitude = storeLocation?.longitude, let latitudeObj = CLLocationDegrees(latitude), let longitudeObj = CLLocationDegrees(longitude) { switch self.locationManager.authorizationStatus { case .notDetermined, .restricted, .denied: print("No access") self.region = MKCoordinateRegion(center:CLLocationCoordinate2D(latitude: latitudeObj, longitude: longitudeObj), span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01)) case .authorizedAlways, .authorizedWhenInUse: print("Access") if CLLocationCoordinate2DIsValid(CLLocationCoordinate2D(latitude: self.userLat, longitude: self.userLng)) && CLLocationCoordinate2DIsValid(CLLocationCoordinate2D(latitude: latitudeObj, longitude: longitudeObj)) { self.region = MKCoordinateRegion(coordinates: [CLLocationCoordinate2D(latitude: self.userLat, longitude: self.userLng), CLLocationCoordinate2D(latitude: latitudeObj, longitude: longitudeObj)]) } else { showErrorAlert = true locationAlert = .failure serverErrorMessage = "Location is not valid." } @unknown default: break } } }