Skip to content

Commit a9a461a

Browse files
committed
feat: add HERE map provider to reactnative-basic example
Add reactnative-for-here submodule and wire the HERE provider into the React Native basic example across all map pages. Simplify the Android build to use the published npm packages instead of local project includes, inject HERE credentials via manifest placeholders, and switch example marker/image drawables from webp to png/jpg.
1 parent b3430ab commit a9a461a

57 files changed

Lines changed: 192 additions & 335 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@
3434
[submodule "react-for-here"]
3535
path = react-for-here
3636
url = ./react-for-here
37+
[submodule "reactnative-for-here"]
38+
path = reactnative-for-here
39+
url = ./reactnative-for-here

examples/basic/firebase.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"hosting": {
3+
"site": "mapconductor-react",
34
"public": "dist",
45
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
56
"cleanUrls": true,

examples/reactnative-basic/App.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from 'react-native';
1414
import { MapScreen } from 'src/screens/MapScreen';
1515

16-
type MapProvider = 'google-maps' | 'maplibre';
16+
type MapProvider = 'google-maps' | 'maplibre' | 'here';
1717

1818
export interface SamplePageDefinition {
1919
id: string;
@@ -62,7 +62,12 @@ function Header({
6262
onProviderChange: (provider: MapProvider) => void;
6363
}) {
6464
const [isProviderMenuOpen, setIsProviderMenuOpen] = useState(false);
65-
const providerLabel = provider === 'google-maps' ? 'GoogleMapView' : 'MapLibreMapView';
65+
const providerLabel =
66+
provider === 'google-maps'
67+
? 'GoogleMapView'
68+
: provider === 'here'
69+
? 'HereMapView'
70+
: 'MapLibreMapView';
6671

6772
const selectProvider = (nextProvider: MapProvider) => {
6873
onProviderChange(nextProvider);
@@ -142,6 +147,20 @@ function Header({
142147
MapLibreMapView
143148
</Text>
144149
</TouchableOpacity>
150+
<TouchableOpacity
151+
style={[styles.providerMenuItem, provider === 'here' && styles.providerMenuItemActive]}
152+
activeOpacity={0.75}
153+
onPress={() => selectProvider('here')}
154+
>
155+
<Text
156+
style={[
157+
styles.providerMenuItemText,
158+
provider === 'here' && styles.providerMenuItemTextActive,
159+
]}
160+
>
161+
HereMapView
162+
</Text>
163+
</TouchableOpacity>
145164
</View>
146165
</View>
147166
</Modal>

examples/reactnative-basic/android/app/build.gradle

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,21 @@ apply plugin: "org.jetbrains.kotlin.android"
33
apply plugin: "com.facebook.react"
44

55
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
6-
def resolveNodeExecutable = {
7-
def properties = new Properties()
8-
def localPropertiesFiles = [
9-
new File(rootDir, "local.properties"),
10-
new File(rootDir.parentFile, "local.properties"),
11-
new File(rootDir.parentFile.parentFile, "local.properties"),
12-
]
13-
localPropertiesFiles.findAll { it.exists() }.each { file ->
14-
file.withInputStream { properties.load(it) }
15-
}
16-
17-
def nodeExecutable = properties.getProperty("NODE_BINARY") ?:
18-
properties.getProperty("nodeExecutable") ?:
19-
System.getenv("NODE_BINARY")
20-
21-
return nodeExecutable ?: "node"
22-
}
23-
def nodeExecutable = resolveNodeExecutable()
24-
def nodeCommand = { String expression ->
25-
return [nodeExecutable, "--print", expression].execute(null, rootDir).text.trim()
26-
}
27-
def loadGoogleMapsApiKey = {
28-
def properties = new Properties()
29-
def localPropertiesFiles = [
30-
new File(rootDir, "local.properties"),
31-
new File(rootDir.parentFile, "local.properties"),
32-
new File(rootDir.parentFile.parentFile, "local.properties"),
33-
]
34-
localPropertiesFiles.findAll { it.exists() }.each { file ->
35-
file.withInputStream { properties.load(it) }
36-
}
37-
38-
return properties.getProperty("ANDROID_GOOGLE_MAPS_API_KEY")
39-
?: properties.getProperty("GOOGLE_MAPS_API_KEY")
40-
?: findProperty("ANDROID_GOOGLE_MAPS_API_KEY")
41-
?: findProperty("GOOGLE_MAPS_API_KEY")
42-
?: System.getenv("ANDROID_GOOGLE_MAPS_API_KEY")
43-
?: System.getenv("GOOGLE_MAPS_API_KEY")
44-
?: ""
45-
}
46-
def googleMapsApiKey = loadGoogleMapsApiKey()
476

487
/**
498
* This is the configuration block to customize your React Native Android app.
509
* By default you don't need to apply any configuration, just uncomment the lines you need.
5110
*/
5211
react {
53-
entryFile = file([nodeExecutable, "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim())
54-
reactNativeDir = new File(nodeCommand("require.resolve('react-native/package.json')")).getParentFile().getAbsoluteFile()
55-
hermesCommand = new File(nodeCommand("require.resolve('hermes-compiler/package.json', { paths: [require.resolve('react-native/package.json')] })")).getParentFile().getAbsolutePath() + "/hermesc/%OS-BIN%/hermesc"
56-
codegenDir = new File(nodeCommand("require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })")).getParentFile().getAbsoluteFile()
12+
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim())
13+
reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
14+
hermesCommand = new File(["node", "--print", "require.resolve('hermes-compiler/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/hermesc/%OS-BIN%/hermesc"
15+
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
5716

5817
enableBundleCompression = (findProperty('android.enableBundleCompression') ?: false).toBoolean()
5918
// Use Expo CLI to bundle the app, this ensures the Metro config
6019
// works correctly with Expo projects.
61-
cliFile = new File(nodeCommand("require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"))
20+
cliFile = new File(["node", "--print", "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })"].execute(null, rootDir).text.trim())
6221
bundleCommand = "export:embed"
6322

6423
/* Folders */
@@ -131,13 +90,19 @@ android {
13190
namespace 'com.mapconductor.basic'
13291
defaultConfig {
13392
applicationId 'com.mapconductor.basic'
134-
minSdkVersion rootProject.ext.minSdkVersion
93+
minSdkVersion 26
13594
targetSdkVersion rootProject.ext.targetSdkVersion
13695
versionCode 1
13796
versionName "1.0.0"
13897

13998
buildConfigField "String", "REACT_NATIVE_RELEASE_LEVEL", "\"${findProperty('reactNativeReleaseLevel') ?: 'stable'}\""
140-
manifestPlaceholders["googleMapsApiKey"] = googleMapsApiKey
99+
100+
// Set directly here (rather than relying solely on reactnative-for-here's own
101+
// rootProject.subprojects manifestPlaceholders hook) for reliability during local testing.
102+
def localProps = new Properties()
103+
file("${rootDir}/local.properties").withInputStream { localProps.load(it) }
104+
manifestPlaceholders["hereAccessKeyId"] = localProps.getProperty("HERE_ACCESS_KEY_ID", "")
105+
manifestPlaceholders["hereAccessKeySecret"] = localProps.getProperty("HERE_ACCESS_KEY_SECRET", "")
141106
}
142107
signingConfigs {
143108
debug {
@@ -197,11 +162,6 @@ android {
197162
dependencies {
198163
// The version of react-native is set by the React Native Gradle Plugin
199164
implementation("com.facebook.react:react-android")
200-
implementation project(':mapconductor_react-for-googlemaps')
201-
implementation project(':mapconductor_react-for-maplibre')
202-
implementation project(':mapconductor_react-marker-clustering')
203-
implementation project(':mapconductor_react-geojson-layer')
204-
implementation project(':mapconductor_react-heatmap')
205165

206166
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
207167
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";

examples/reactnative-basic/android/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
</intent>
1313
</queries>
1414
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:supportsRtl="true" android:enableOnBackInvokedCallback="false">
15+
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyBF3OFr8vmZllleUhThyReKbxnI5c69Py4" tools:replace="android:value"/>
1516
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
1617
<meta-data android:name="expo.modules.updates.ENABLE_BSDIFF_PATCH_SUPPORT" android:value="true"/>
1718
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
1819
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
19-
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|smallestScreenSize" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
20+
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|smallestScreenSize|assetsPaths" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
2021
<intent-filter>
2122
<action android:name="android.intent.action.MAIN"/>
2223
<category android:name="android.intent.category.LAUNCHER"/>
2324
</intent-filter>
2425
</activity>
2526
</application>
26-
</manifest>
27+
</manifest>

examples/reactnative-basic/android/app/src/main/java/com/mapconductor/basic/ExampleGeoJSONStyler.kt

Lines changed: 0 additions & 90 deletions
This file was deleted.

examples/reactnative-basic/android/app/src/main/java/com/mapconductor/basic/MainApplication.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ import com.facebook.react.ReactPackage
1010
import com.facebook.react.ReactHost
1111
import com.facebook.react.common.ReleaseLevel
1212
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint
13-
import com.mapconductor.react.googlemaps.MapConductorGoogleMapsPackage
14-
import com.mapconductor.react.maplibre.MapConductorMapLibrePackage
15-
import com.mapconductor.react.geojson.GeoJSONStyleProviderRegistry
1613

1714
import expo.modules.ApplicationLifecycleDispatcher
1815
import expo.modules.ExpoReactHostFactory
@@ -26,18 +23,12 @@ class MainApplication : Application(), ReactApplication {
2623
PackageList(this).packages.apply {
2724
// Packages that cannot be autolinked yet can be added manually here, for example:
2825
// add(MyReactNativePackage())
29-
add(MapConductorGoogleMapsPackage())
30-
add(MapConductorMapLibrePackage())
3126
}
3227
)
3328
}
3429

3530
override fun onCreate() {
3631
super.onCreate()
37-
GeoJSONStyleProviderRegistry.register("example-n02-route") { context, sourceUri ->
38-
requireNotNull(sourceUri) { "example-n02-route requires a GeoJSON ZIP sourceUri" }
39-
ExampleGeoJSONStyler.fromZip(context, sourceUri)
40-
}
4132
DefaultNewArchitectureEntryPoint.releaseLevel = try {
4233
ReleaseLevel.valueOf(BuildConfig.REACT_NATIVE_RELEASE_LEVEL.uppercase())
4334
} catch (e: IllegalArgumentException) {
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)