Skip to content

Commit

Permalink
iOS: fix optionals
Browse files Browse the repository at this point in the history
- iOS: fix Optionals for latitude and longitude in reverse geocoding
  • Loading branch information
sebastianbaar committed Mar 13, 2019
1 parent 56b4554 commit 79e778e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.2.1 (2019-03-13)

- iOS: fix Optionals for latitude and longitude in reverse geocoding

# 3.2.0 (2019-03-10)

- result array returns the same information for forward and reverse geocoding (closes #35)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-nativegeocoder",
"version": "3.2.0",
"version": "3.2.1",
"description": "Cordova plugin for native forward and reverse geocoding",
"cordova": {
"id": "cordova-plugin-nativegeocoder",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<plugin id="cordova-plugin-nativegeocoder" version="3.2.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="cordova-plugin-nativegeocoder" version="3.2.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>NativeGeocoder</name>
<description>Cordova plugin for native forward and reverse geocoding</description>
<license>MIT</license>
Expand Down
14 changes: 10 additions & 4 deletions src/ios/NativeGeocoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,17 @@ struct NativeGeocoderOptions: Decodable {

for i in 0..<maxResultObjects {
// https://developer.apple.com/documentation/corelocation/clplacemark
let latitude = placemarks[i].location?.coordinate.latitude
let longitude = placemarks[i].location?.coordinate.longitude
var latitude = ""
if let lat = placemarks[i].location?.coordinate.latitude {
latitude = "\(lat)"
}
var longitude = ""
if let lon = placemarks[i].location?.coordinate.longitude {
longitude = "\(lon)"
}
let placemark = NativeGeocoderResult(
latitude: (latitude != nil) ? "\(String(describing: latitude))" : "",
longitude: (longitude != nil) ? "\(String(describing: longitude))" : "",
latitude: latitude,
longitude: longitude,
countryCode: placemarks[i].isoCountryCode ?? "",
countryName: placemarks[i].country ?? "",
postalCode: placemarks[i].postalCode ?? "",
Expand Down

0 comments on commit 79e778e

Please sign in to comment.