Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configs/e2e/native_dependencies.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"react-native-maps": "1.27.2",
"react-native-geocoder": "0.5.0",
"react-native-device-info": "15.0.2",
"react-native-action-button": "2.8.5",
"react-native-material-menu": "1.2.0",
Expand All @@ -12,6 +11,7 @@
"react-native-vision-camera": "5.2.3",
"react-native-vision-camera-barcode-scanner": "5.2.3",
"react-native-nitro-modules": "0.37.0",
"react-native-nitro-geolocation": "2.0.3",
"react-native-nitro-image": "0.15.2",
"react-native-view-shot": "5.1.0",
"react-native-blob-util": "0.24.11",
Expand Down
6 changes: 6 additions & 0 deletions packages/jsActions/nanoflow-actions-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Changed

- Migrated the "Geocode" action from the unmaintained `react-native-geocoder` to `react-native-nitro-geolocation` on native. When native geocoding fails or finds no results and a geocoding provider and API key are configured, the action now falls back to that provider.
- Migrated the "Reverse geocode" action from the unmaintained `react-native-geocoder` to `react-native-nitro-geolocation` on native. When native reverse geocoding fails or returns no address and a geocoding provider and API key are configured, the action now falls back to that provider. On iOS, the returned address is now composed by `react-native-nitro-geolocation` and can be formatted differently than before.

## [8.0.1] Nanoflow Commons - 2026-11-25

### Fixed

- Fixed an issue where the "Get straight line distance" action threw an error at runtime.
Expand Down
5 changes: 2 additions & 3 deletions packages/jsActions/nanoflow-actions-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
"mendix-native": "https://github.com/mendix/mendix-native/releases/download/v1.0.0/mendix-native-v1.0.0.tgz",
"react-native-nitro-geolocation": "2.0.3",
"react-native-nitro-modules": "0.37.0",
"react-native-permissions": "5.5.1",
"react-native-geocoder": "0.5.0"
"react-native-permissions": "5.5.1"
},
"devDependencies": {
"@mendix/pluggable-widgets-tools": "*",
"mendix": "11.8.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import Geodecoder from "react-native-geocoder";
import { geocode } from "react-native-nitro-geolocation";

// BEGIN EXTRA CODE
// END EXTRA CODE
Expand All @@ -27,7 +27,7 @@ export async function Geocode(
// BEGIN USER CODE
/**
* Documentation:
* - Native: https://github.com/devfd/react-native-geocoder
* - Native: https://react-native-nitro-geolocation.pages.dev/guide/modern-api
* - Google: https://developers.google.com/maps/documentation/geocoding/intro#GeocodingRequests
* - Geocodio: https://www.geocod.io/docs/#geocoding
* - LocationIQ: https://locationiq.com/docs-html/index.html#search-forward-geocoding
Expand All @@ -39,12 +39,26 @@ export async function Geocode(
}

if (navigator && navigator.product === "ReactNative") {
return Geodecoder.geocodeAddress(address).then(results => {
if (results.length === 0) {
return Promise.reject(new Error("No results found"));
let nativeError: Error;
try {
const results = await geocode(address);
if (results.length > 0) {
// Returned (not awaited) on purpose: a failure to create the Mendix object must not
// trigger the provider fallback below.
return createMxObject(String(results[0].latitude), String(results[0].longitude));
}
return createMxObject(String(results[0].position.lat), String(results[0].position.lng));
});
nativeError = new Error("No results found");
} catch (error: any) {
// react-native-nitro-geolocation rejects with a plain `{ code, message }` object, not an Error.
nativeError = error instanceof Error ? error : new Error(error?.message ?? String(error));
}

// Without provider configuration there is nothing to fall back to, so report the native failure.
if (!geocodingProvider || !providerApiKey) {
return Promise.reject(nativeError);
}

return geocodeWithProvider(geocodingProvider, address, providerApiKey);
}

if (!geocodingProvider) {
Expand All @@ -55,19 +69,27 @@ export async function Geocode(
return Promise.reject(new Error("Input parameter 'Provider api key' is required for use on web"));
}

const url = getApiUrl(geocodingProvider, address, providerApiKey);
return geocodeWithProvider(geocodingProvider, address, providerApiKey);

function geocodeWithProvider(
provider: GeocodingProvider,
query: string,
key: string
): Promise<mendix.lib.MxObject> {
const url = getApiUrl(provider, query, key);

return fetch(url)
.then(response =>
response.json().catch(() =>
response.text().then(text => {
return Promise.reject(new Error(text));
})
return fetch(url)
.then(response =>
response.json().catch(() =>
response.text().then(text => {
return Promise.reject(new Error(text));
})
)
)
)
.then(response => getLatLong(geocodingProvider, response))
.then(latLong => createMxObject(latLong[0], latLong[1]))
.catch(error => Promise.reject(error));
.then(response => getLatLong(provider, response))
.then(latLong => createMxObject(latLong[0], latLong[1]))
.catch(error => Promise.reject(error));
}

function getApiUrl(provider: GeocodingProvider, query: string, key: string): string {
query = encodeURIComponent(query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import Geodecoder from "react-native-geocoder";
import { reverseGeocode } from "react-native-nitro-geolocation";

// BEGIN EXTRA CODE
// END EXTRA CODE
Expand All @@ -29,7 +29,7 @@ export async function ReverseGeocode(
// BEGIN USER CODE
/**
* Documentation:
* - Native: https://github.com/devfd/react-native-geocoder
* - Native: https://react-native-nitro-geolocation.pages.dev/guide/modern-api
* - Google: https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding
* - Geocodio: https://www.geocod.io/docs/#reverse-geocoding
* - LocationIQ: https://locationiq.com/docs-html/index.html#reverse-geocoding
Expand All @@ -45,14 +45,26 @@ export async function ReverseGeocode(
}

if (navigator && navigator.product === "ReactNative") {
const position = { lat: Number(latitude), lng: Number(longitude) };

return Geodecoder.geocodePosition(position).then(results => {
if (results.length === 0) {
return Promise.reject(new Error("No results found"));
let nativeError: Error;
try {
const results = await reverseGeocode({ latitude: Number(latitude), longitude: Number(longitude) });
// Every field of a native result is optional, so use the first result that has an address.
const address = results.find(result => result.formattedAddress)?.formattedAddress;
if (address) {
return address;
}
return results[0].formattedAddress;
});
nativeError = new Error("No results found");
} catch (error: any) {
// react-native-nitro-geolocation rejects with a plain `{ code, message }` object, not an Error.
nativeError = error instanceof Error ? error : new Error(error?.message ?? String(error));
}

// Without provider configuration there is nothing to fall back to, so report the native failure.
if (!geocodingProvider || !providerApiKey) {
return Promise.reject(nativeError);
}

return reverseGeocodeWithProvider(geocodingProvider, latitude, longitude, providerApiKey);
}

if (!geocodingProvider) {
Expand All @@ -63,22 +75,27 @@ export async function ReverseGeocode(
return Promise.reject(new Error("Input parameter 'Provider api key' is required for use on web"));
}

latitude = encodeURIComponent(latitude);
longitude = encodeURIComponent(longitude);
providerApiKey = encodeURIComponent(providerApiKey);
return reverseGeocodeWithProvider(geocodingProvider, latitude, longitude, providerApiKey);

const url = getApiUrl(geocodingProvider, latitude, longitude, providerApiKey);
function reverseGeocodeWithProvider(
provider: ReverseGeocodingProvider,
lat: string,
long: string,
key: string
): Promise<string> {
const url = getApiUrl(provider, encodeURIComponent(lat), encodeURIComponent(long), encodeURIComponent(key));

return fetch(url)
.then(response =>
response.json().catch(() =>
response.text().then(text => {
return Promise.reject(new Error(text));
})
return fetch(url)
.then(response =>
response.json().catch(() =>
response.text().then(text => {
return Promise.reject(new Error(text));
})
)
)
)
.then(response => getAddress(geocodingProvider, response))
.catch(error => Promise.reject(error));
.then(response => getAddress(provider, response))
.catch(error => Promise.reject(error));
}

function getApiUrl(provider: ReverseGeocodingProvider, lat: string, long: string, key: string): string {
switch (provider) {
Expand Down

This file was deleted.

4 changes: 4 additions & 0 deletions packages/pluggableWidgets/maps-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Changed

- We replaced the unmaintained `react-native-geocoder` with `react-native-nitro-geolocation` for resolving marker addresses to coordinates.

## [5.3.0] - 2026-11-25

### Changed
Expand Down
7 changes: 4 additions & 3 deletions packages/pluggableWidgets/maps-native/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "maps-native",
"widgetName": "Maps",
"version": "5.3.0",
"version": "5.3.1",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand All @@ -22,8 +22,9 @@
"@mendix/piw-native-utils-internal": "*",
"@mendix/piw-utils-internal": "*",
"prop-types": "15.8.1",
"react-native-geocoder": "0.5.0",
"react-native-maps": "1.27.2"
"react-native-maps": "1.27.2",
"react-native-nitro-geolocation": "2.0.3",
"react-native-nitro-modules": "0.37.0"
},
"devDependencies": {
"@mendix/pluggable-widgets-tools": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Maps, Props } from "../Maps";
import { render, act } from "@testing-library/react-native";
import { dynamicValue } from "@mendix/piw-utils-internal";
import { Big } from "big.js";
import { Marker } from "react-native-maps";
import { geocode } from "react-native-nitro-geolocation";

// Mock react-native-maps
// Without this, the Maps component renders only an empty AIRMap component without markers
Expand Down Expand Up @@ -42,10 +44,18 @@ jest.mock("react-native-maps", () => {
};
});

// Nitro modules load their native implementation on import, which is not available in Jest
jest.mock("react-native-nitro-geolocation", () => ({
geocode: jest.fn(() => Promise.resolve([]))
}));

const mockGeocode = geocode as jest.MockedFunction<typeof geocode>;

describe("<Maps />", () => {
let defaultProps: Props;

beforeEach(() => {
mockGeocode.mockClear();
defaultProps = {
name: "maps-test",
style: [],
Expand Down Expand Up @@ -89,4 +99,33 @@ describe("<Maps />", () => {

expect(component.toJSON()).toMatchSnapshot();
});

it("places a marker defined by an address at the geocoded coordinates", async () => {
mockGeocode.mockResolvedValueOnce([
{ latitude: 52.3731, longitude: 4.8926 },
{ latitude: 1, longitude: 1 }
]);
defaultProps.markers = [
{
locationType: "address",
address: dynamicValue("Dam, Amsterdam", false),
iconSize: 1,
iconColor: "red"
}
];

const component = render(<Maps {...defaultProps} />);

await act(async () => {
await new Promise(resolve => setTimeout(resolve, 0));
});

expect(mockGeocode).toHaveBeenCalledTimes(1);
expect(mockGeocode).toHaveBeenCalledWith("Dam, Amsterdam");
// The first result is used
expect(component.UNSAFE_getByType(Marker).props.coordinate).toEqual({
latitude: 52.3731,
longitude: 4.8926
});
});
});
2 changes: 1 addition & 1 deletion packages/pluggableWidgets/maps-native/src/package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="Maps" version="5.3.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="Maps" version="5.3.1" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="Maps.xml" />
</widgetFiles>
Expand Down
Loading
Loading