Giter Site home page Giter Site logo

react-native-geocoder's Introduction

react-native-geocoder

CircleCI

geocoding services for react native

Version table

Geocoder Version RN
>=0.5.0 >= 0.47.0
>=0.4.6 >= 0.40.0
<0.4.5 <0.40.0

Install

npm install --save react-native-geocoder

iOS

  1. In the XCode's "Project navigator", right click on Libraries folder under your project ➜ Add Files to <...>
  2. Go to node_modulesreact-native-geocoder and add ios/RNGeocoder.xcodeproj file
  3. Add libRNGeocoder.a to "Build Phases" -> "Link Binary With Libraries"

Android

  1. In android/setting.gradle
...
include ':react-native-geocoder', ':app'
project(':react-native-geocoder').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-geocoder/android')
  1. In android/app/build.gradle
...
dependencies {
    ...
    compile project(':react-native-geocoder')
}
  1. register module (in MainApplication.java)
import com.devfd.RNGeocoder.RNGeocoderPackage; // <--- import

public class MainActivity extends ReactActivity {
  ......

  @Override
  protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new RNGeocoderPackage()); // <------ add this
  }

  ......

}

Usage

import Geocoder from 'react-native-geocoder';

// Position Geocoding
var NY = {
  lat: 40.7809261,
  lng: -73.9637594
};

Geocoder.geocodePosition(NY).then(res => {
    // res is an Array of geocoding object (see below)
})
.catch(err => console.log(err))

// Address Geocoding
Geocoder.geocodeAddress('New York').then(res => {
    // res is an Array of geocoding object (see below)
})
.catch(err => console.log(err))

Fallback to google maps geocoding

Geocoding services might not be included in some Android devices (Kindle, some 4.1 devices, non-google devices). For those special cases the lib can fallback to the online google maps geocoding service

import Geocoder from 'react-native-geocoder';
// simply add your google key
Geocoder.fallbackToGoogle(MY_KEY);

// use the lib as usual
let ret = await Geocoder.geocodePosition({lat, lng})
// you get the same results

With async / await

try {

    const res = await Geocoder.geocodePosition(NY);
    ...

    const res = await Geocoder.geocodeAddress('London');
    ...
}
catch(err) {
    console.log(err);
}

Geocoding object format

both iOS and Android will return the following object:

{
    position: {lat, lng},
    formattedAddress: String, // the full address
    feature: String | null, // ex Yosemite Park, Eiffel Tower
    streetNumber: String | null,
    streetName: String | null,
    postalCode: String | null,
    locality: String | null, // city name
    country: String,
    countryCode: String
    adminArea: String | null
    subAdminArea: String | null,
    subLocality: String | null
}

Notes

iOS

iOS does not allow sending multiple geocoding requests simultaneously, hence if you send a second call, the first one will be cancelled.

Android

geocoding may not work on older android devices (4.1) and will not work if Google play services are not available.

react-native-geocoder's People

Contributors

alexeypodolian avatar danielweinmann avatar devfd avatar ehesp avatar jgaudette avatar juellez avatar mikelambert avatar oblador avatar oney avatar patoroco avatar rollacaster avatar rorycombe avatar tszajna0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-geocoder's Issues

Lint error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-geocoder:lint'.

Lint found errors in the project; aborting build.

InvalidPackage: Package not included in Android
../../../../../../../.m2/repository/com/squareup/okio/okio/1.9.0/okio-1.9.0.jar: Invalid package reference in library; not included in Android: java.nio.file. Referenced from okio.Okio.

to fix this you can add in build.gradle

lintOptions {
        disable 'InvalidPackage'
}

Question: What is the usage limitation?

Currently I do GeoCoding on my server using MapQuest and I have a limitation. Should I move the GeoCoding to the device using this package and if so, what limitations would I have? Do I have to sign up for any service to support this?

Thanks.

Differing Property Names between iOS and Android

The object returned by reverseGeocodeLocation differs between iOS and Android - most notable is that the longitude/latitude are contained in the location property on iOS but are instead found within the position property on Android. It should probably be consistent (though easily circumvented in code).

"illegal start of type List<NativeModule> modules = new ArrayList<>()" when compiling with react-native run-android

:RNGeocoder:generateReleaseSources
:RNGeocoder:processReleaseJavaRes UP-TO-DATE
:RNGeocoder:compileReleaseJavaWithJavac
/Users/danielweinmann/projects/TemAcucar/node_modules/react-native-geocoder/android/src/main/java/com/devfd/RNGeocoder/RNGeocoderPackage.java:18: illegal start of type
    List<NativeModule> modules = new ArrayList<>();
                                               ^
1 error
:RNGeocoder:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':RNGeocoder:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I'm having this problem when tying to run a project on android with "react-native run-android".

I'm using React Native 0.19.0 and react-native-geocoder 0.3.0, on OSX El Capitan. Do you know what can I do to fix this?

adminArea on Android is different than on IOS

On IOS, the adminArea returned by a call to geocoder.geocodePosition(pos) is a two letter state name in the US. (ie 'AL') On Android, it is returning the full state name (ie 'Alabama'). This should be consistent.

Cannot read property 'geocodePosition' of undefined

import Geocoder from 'react-native-geocoder';
componentDidUpdate() {
        if (this.props.Local != null) {
            let location = {
                lat: this.props.Local.latitude,
                lng: this.props.Local.longitude
            }

            console.log(location)
            Geocoder.geocodePosition(location)
                .then(res => console.log(res));

        }
    }

I cannot get rid of this error.

Android/Java Override build error

During a most recent build, I received the following error:

:react-native-geocoder:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/App/node_modules/react-native-geocoder/android/src/main/java/com/devfd/RNGeocoder/RNGeocoderPackage.java:23: error: method does not override or implement a method from a supertype
  @Override
  ^
1 error
:react-native-geocoder:compileReleaseJavaWithJavac FAILED

It looks like there is a Java syntax error.

Build compilation problem

Hi,
I get the following errors during my build:

/GeoCoderTest/android/app/src/main/java/com/geocodertest/MainActivity.java:16: error: cannot find symbol
    protected List<ReactPackage> getPackages() {
              ^
  symbol:   class List
  location: class MainActivity
GeoCoderTest/android/app/src/main/java/com/geocodertest/MainActivity.java:16: error: cannot find symbol
    protected List<ReactPackage> getPackages() {
                   ^
  symbol:   class ReactPackage
  location: class MainActivity
/GeoCoderTest/android/app/src/main/java/com/geocodertest/MainActivity.java:15: error: method does not override or implement a method from a supertype
    @Override
    ^
GeoCoderTest/android/app/src/main/java/com/geocodertest/MainActivity.java:18: error: cannot find symbol
          new MainReactPackage(),
              ^
  symbol:   class MainReactPackage
  location: class MainActivity
/GeoCoderTest/android/app/src/main/java/com/geocodertest/MainActivity.java:17: error: cannot find symbol
        return Arrays.<ReactPackage>asList(
                       ^
  symbol:   class ReactPackage
  location: class MainActivity
/GeoCoderTest/android/app/src/main/java/com/geocodertest/MainActivity.java:17: error: cannot find symbol
        return Arrays.<ReactPackage>asList(
               ^
  symbol:   variable Arrays
  location: class MainActivity
6 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.

I tried importing java.util.Arrays, java.util.List, However I was not sure of the ReactPackage and MainReactPackage classes and also the @OverRide annotation.

Looking forward for a feasible fix.

undefined is not an object (evaluating 'RNGeocoder.geocodePosition')

Im getting this message, when trying to do reverse geocoding on rn using this package.

The code is as follows:

import Geocoder from 'react-native-geocoder';
locationPos = {
      lat: positionToInsert.latitude,
      lng: positionToInsert.longitude
    }
Geocoder.geocodePosition(locationPos).then(res => {
      this.setState({locPos: res[0].formattedAddress})
    })
    .catch(err => console.log(err))

Provide info in README on Errors

Consider providing more info on the error type and error messages that could occur. I just peeked in the source, it looks like all promise rejections are using the generic Error type.

I can make a PR for adding some of this info if you are interested!

Cannot read property 'geocodePosition' of undefined

This is my code:

import React, { Component } from 'react';
import { 
  AppRegistry, 
  View, 
  Text
} from 'react-native';
import Geocoder from 'react-native-geocoder'; // 0.5.0

Geocoder.apiKey = '__API__KEY__';

export default class teste47 extends Component {
  constructor(props) {
    super(props);

    this.state = {
      latitude: null,
      longitude: null,
      place: 'Localizando endereço...',
      error: null,
    };
  }

  componentDidMount() {
   navigator.geolocation.getCurrentPosition(
    position => {
      this.setState(
        {
          latitude: position.coords.latitude,
          longitude: position.coords.longitude,
          error: null,
        },
        () => {
          Geocoder.geocodePosition({
            lat: this.state.latitude,
            lng: this.state.longitude,
          }).then(res => {
            this.setState({
              place: res[0].formattedAddress,
            });
          });
        }
      );
    },
    error => this.setState({ error: error.message }),
    { enableHighAccuracy: true, timeout: 20000 }
  );
 }

  render() {
    return (
      <View style={{ flexGrow: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>Latitude: {this.state.latitude}</Text>
        <Text>Longitude: {this.state.longitude}</Text>
        <Text>{this.state.place.toString()}</Text>
        {this.state.error ? <Text>Error: {this.state.error}</Text> : null}
      </View>
    );
  }
}

AppRegistry.registerComponent('teste47', () => teste47);

I created the project with react-native init I added the <uses-permission android: name = "android.permission.ACCESS_FINE_LOCATION" /> to AndroidManifest.xml and I used the react-native link to link.

But when I run the project this returns latitude and longitude to then display an error screen:

screenshot_1508871624

I really have not found the error, what can it be?

Prod build failed - Failed to minify the code from this file: ./node_modules/react-geocode/lib/index.js:1

Logs :

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]prebuild: [email protected]
6 info lifecycle [email protected]
build: [email protected]
7 verbose lifecycle [email protected]build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]
build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/guillaume/Documents/Web Developpement/React/pharma-express/node_modules/.bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
9 verbose lifecycle [email protected]build: CWD: /Users/guillaume/Documents/Web Developpement/React/pharma-express
10 silly lifecycle [email protected]
build: Args: [ '-c', 'react-scripts build' ]
11 silly lifecycle [email protected]build: Returned: code: 1 signal: null
12 info lifecycle [email protected]
build: Failed to exec build script
13 verbose stack Error: [email protected] build: react-scripts build
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:283:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd /Users/guillaume/Documents/Web Developpement/React/pharma-express
16 verbose Darwin 17.4.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v8.9.1
19 verbose npm v5.8.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] build: react-scripts build
22 error Exit status 1
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

An option to use google API on iOS?

The library does a great job parsing and formatting the addresses, and giving a common usable format. But the default iOS reverse-geocoding (from position to address) is not very good for all countries (example : India, where the google API is much better)

Can we have an option to use the Google API on iOS ?

get my current location city name

Hi I have tried to get the current location city name but i cant get it. Can anyone help me on this issue?? I'm not at getting the response. Wrote this code in componentdidmount()

Code:

navigator.geolocation.getCurrentPosition(
          (position) => {
            try {
                Geocoder.geocodePosition({ position.coords.latitude, position.coords.longitude }.then(res =>
                     console.log(res)
            } catch(err) {
              console.log(err);
            }
          },
          (error) => this.setState({ error: error.message }),
          { enableHighAccuracy: false, timeout: 200000, maximumAge: 1000 },
        );

Time out server

When I first installed geocoder in my project everything worked fine, but after a while I got this error: Error:
Timed out waiting for response from server.

And its not working anymore.

Please help! Thanks!

Explain "Add to Xcode Project"

Please excuse my rookie question, but can you describe the steps for:

Then add RNGeocoder folder to your xcode project.

in more detail?

Thanks!

get the locality of the place

Why does it gives 10 outcomes in the following code? How can I get the city name only? I've tested in android devices.

	var NY = {
	  lat: 40.7809261,
	  lng: -73.9637594,
	};

	export default class App extends Component<Props> {


	  currentArea = () => {
		Geocoder.geocodePosition(NY).then(res => {
			console.log('position', res);
		})
		.catch(err => console.log(err))
	  }
	  render() {
		return (
		  <View>
			<TouchableOpacity
			  onPress={() => this.currentArea()}
			>
			  <Text>Get current location</Text>
			</TouchableOpacity>
		  </View>
		);
	  }
	}

Debugged value:

position 
(10) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0
:
{streetName: "East Drive", feature: null, locale: "en_GB", locality: "New York", position: {…}, …}
1
:
{streetName: null, feature: "Central Park", locale: "en_GB", locality: "New York", position: {…}, …}
2
:
{streetName: null, feature: "Manhattan", locale: "en_GB", locality: "New York", position: {…}, …}
3
:
{streetName: null, feature: null, locale: "en_GB", locality: "New York", position: {…}, …}
4
:
{streetName: null, feature: "10028", locale: "en_GB", locality: "New York", position: {…}, …}
5
:
{streetName: null, feature: "New York County", locale: "en_GB", locality: "New York", position: {…}, …}
6
:
{streetName: null, feature: "New York-Northern New Jersey-Long Island, NY-NJ-PA", locale: "en_GB", locality: null, position: {…}, …}
7
:
{streetName: null, feature: "New York Metropolitan Area", locale: "en_GB", locality: null, position: {…}, …}
8
:
{streetName: null, feature: "New York", locale: "en_GB", locality: null, position: {…}, …}
9
:
{streetName: null, feature: "United States", locale: "en_GB", locality: null, position: {…}, …}
length
:
10
__proto__
:
Array(0)

Receiving empty data

I am testing on an android device (redmi 3 with android 5.1.1 and Google play service installed) and I defined a google api key (server key) but I always receive empty data (no error) no matter what address I passed to the service (I tried 'New York' or 'london' like in the readme or test files so as more complete address with street, postcode, country... but it doesn't work)
What am I missing here?

Android: Failed to execute aapt on release build

Hi, guys.

I tried to create a release build, and got the error below.

Execution failed for task ':react-native-geocoder:verifyReleaseResources'. com.android.ide.common.process.ProcessException: Failed to execute aapt

The obvious solution would be to disable aapt, but I can't do that because a couple of other libraries i have used in my project require aapt to be enabled.

I use react-native v0.56.0 and react-native-geocoder v0.5.0.

I was wondering if anyone else has run into this same issue, and the steps needed to fix this.

Thank you.

Android: Why fetching 20 addresses?

image
According to API, recommended is 1-5, but in this packager/api was hard - coded as 20. So may not get proper results ...

package API Code:
List<Address> addresses = geocoder.getFromLocation(position.getDouble("lat"), position.getDouble("lng"), 20);

It should be like

List<Address> addresses = geocoder.getFromLocation(position.getDouble("lat"), position.getDouble("lng"), 2);

OR

Give an option to user, so user can pass that value.
Hope you understood, what i am trying to explain..

How to use geocoding?

hey @devfd can you help me how to use it i am bit confused how to integrate it with my current code . I am taking user current location by the following code can you help me how i can integrate geocoeding with it

here is my current code:

navigator.geolocation.getCurrentPosition(
      (position) => {
        this.setState({
          region: {
            latitude: position.coords.latitude,
            longitude: position.coords.longitude, 
            latitudeDelta: LATITUDE_DELTA,
            longitudeDelta: LONGITUDE_DELTA
          }
        });
      },
    );

Security concern for Google Key

import Geocoder from 'react-native-geocoder'; // simply add your google key Geocoder.fallbackToGoogle(MY_KEY);
Is it save to put the KEY on javascript file (client side) ?
Will it not be readable by someone?

MainActivity.java updated, install instructions outdated.

With React 0.18.0-rc the MainActivity.java file has changed. Please update the installation instructions to reflect where we should add .addPackage(new RNGeocoderPackage())

I believe it would be like this: New MainActivty.java:

package com.foo;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.devfd.RNGeocoder.RNGeocoderPackage; // <--- import

import java.util.Arrays;
import java.util.List;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "foo";
    }

    /**
     * Returns whether dev mode should be enabled.
     * This enables e.g. the dev menu.
     */
    @Override
    protected boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
    }

   /**
   * A list of packages used by the app. If the app uses additional views
   * or modules besides the default ones, add more packages here.
   */
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new RNGeocoderPackage()
       );
    }
}

Receiving an array with a lot of objects

Hello,
Reading the README, I was under the impression that the request would return one object with the device's current location. However, when I started testing, I got a huge array with diminishing accuracy. Is that the expected behavior? Is there a pattern to the objects? Is the returned array always the same size?

Also, is it possible to change the locale to get the address in another language?

Code sample:

  componentDidMount() {
    navigator.geolocation.getCurrentPosition(
      (position) => {
        const latLng = { 
          lat: position.coords.latitude, 
          lng: position.coords.longitude
        };

        Geocoder.geocodePosition(latLng).then(res => {
          this.props.setLocation(res);
          console.log(res);
        })
        .catch(err => console.log(err)); 
      },
      (error) => console.log(JSON.stringify(error)),
      { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
    );
  }

latLng:
{ lat: -6.228769999999999, lng: -35.060759999999995 }

res:
[ { streetName: null, feature: null, locale: 'en_US', locality: 'Pipa Beach', position: { lng: -35.0487735, lat: -6.2289986 }, adminArea: 'State of Rio Grande do Norte', streetNumber: null, country: 'Brazil', countryCode: 'BR', postalCode: null, subAdminArea: null, formattedAddress: 'Pipa Beach, Tibau do Sul - State of Rio Grande do Norte, Brazil', subLocality: null }, { streetName: null, feature: null, locale: 'en_US', locality: 'Tibau do Sul', position: { lng: -35.1048713, lat: -6.2211806 }, adminArea: 'State of Rio Grande do Norte', streetNumber: null, country: 'Brazil', countryCode: 'BR', postalCode: null, subAdminArea: null, formattedAddress: 'Tibau do Sul - State of Rio Grande do Norte, Brazil', subLocality: null }, { streetName: null, feature: '59178-000', locale: 'en_US', locality: 'Tibau do Sul', position: { lng: -35.1048713, lat: -6.2211806 }, adminArea: 'State of Rio Grande do Norte', streetNumber: null, country: 'Brazil', countryCode: 'BR', postalCode: '59178-000', subAdminArea: null, formattedAddress: 'Tibau do Sul - State of Rio Grande do Norte, 59178-000, Brazil', subLocality: null }, { streetName: null, feature: 'State of Rio Grande do Norte', locale: 'en_US', locality: null, position: { lng: -36.954107, lat: -5.4025803 }, adminArea: 'State of Rio Grande do Norte', streetNumber: null, country: 'Brazil', countryCode: 'BR', postalCode: null, subAdminArea: null, formattedAddress: 'State of Rio Grande do Norte, Brazil', subLocality: null }, { streetName: null, feature: 'Brazil', locale: 'en_US', locality: null, position: { lng: -51.92528, lat: -14.235004 }, adminArea: null, streetNumber: null, country: 'Brazil', countryCode: 'BR', postalCode: null, subAdminArea: null, formattedAddress: 'Brazil', subLocality: null }, { streetName: 'Rua Flores da Mata', feature: null, locale: 'en_US', locality: 'Tibau do Sul', position: { lng: -35.0597249, lat: -6.2296355 }, adminArea: 'State of Rio Grande do Norte', streetNumber: null, country: 'Brazil', countryCode: 'BR', postalCode: '59178-000', subAdminArea: null, formattedAddress: 'Rua Flores da Mata, Tibau do Sul - RN, 59178-000, Brazil', subLocality: null } ]

Thanks in advance.

All requests have "Not found"

Here is code:

 getGeocodeAddress(user, location) {
    return new Promise(function(resolve,reject) {
      RNGeocoder.geocodeAddress(location, (err, latLong) => {
        if (err) {
          console.log('getGeocodeAddress.err ' + location,err);
          return reject(err);
        }
        console.log('getGeocodeAddress.latLong ' + location, latLong);
        if (latLong) {
          user.lat = latLong[0].location.lat;
          user.long = latLong[0].location.lng;
        }
        return resolve(user);
      });
    });
  }

Here is some output (all requests have "Not found")

StarGazers.js:52 getGeocodeAddress.err Munich Not found
StarGazers.js:52 getGeocodeAddress.err New Delhi, India Not found
StarGazers.js:52 getGeocodeAddress.err Canada Not found
StarGazers.js:52 getGeocodeAddress.err Tokyo, Japan Not found
StarGazers.js:52 getGeocodeAddress.err Seattle, WA Not found
StarGazers.js:52 getGeocodeAddress.err Indonesia Not found
StarGazers.js:52 getGeocodeAddress.err Illinois Not found
StarGazers.js:52 getGeocodeAddress.err Wellington, New Zealand Not found
StarGazers.js:52 getGeocodeAddress.err Netherlands Not found
StarGazers.js:52 getGeocodeAddress.err Washington, DC Not found

Nominatim as fallback?

Is there any plan to also support Nominatim (http://wiki.openstreetmap.org/wiki/Nominatim), from openstreetmap, as a fallback geocoding service rather than google maps?
I think it would be more convenient as Nominatim do not limit in the number of daily requests...

EDIT: geocoding service from mapquest used to be free without limit too but I just saw it is no longuer the case :( . But maybe there is some other completely free geocoding service that could be used as fallback... Just found this one: http://services.gisgraphy.com/public/geocoding.html but it requiere you to host your own server to use it for free (else you have to pay if you want to use premium servers)

geocodePosition failed

I am using react-native-geocoder and I am getting result also but on debugging, I am getting this error -
Error: geocodePosition failed
at createErrorFromErrorData (NativeModules.js:123)
at NativeModules.js:80
at MessageQueue.__invokeCallback (MessageQueue.js:346)
at MessageQueue.js:132
at MessageQueue.__guard (MessageQueue.js:262)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:131)
at debuggerWorker.js:72

react-scripts build failed to compile

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file:

./node_modules/react-native-geocoding/Geocoder.js:6 

npm version is different that github version

Hi,

react-native-geocoder v0.14.0 is different between npmjs.com and github repo.

I discovered that because github repo has android folder, but when I use npm install from npmjs server, it doesn't download this folder. I was looking the .npmignore file (which I discovered that it doesn't make sense and open a #7) and I didn't found any references there to android folder, so I try to download directly from this repo. Result is bellow.

Left side is using npm install react-native-geocoder (from npmjs.com), and right side is using npm install devfd/react-native-geocoder
screen shot 2015-12-16 at 12 58 22

Also should be good if you'd accept #6 because it included interesting info about how to install on Android.

Thanks for your library!

Possible Unhandled Promise Rejection

I get the following warning when I try to run you sample code.

[]([warn][tid:com.facebook.React.JavaScript] Possible Unhandled Promise Rejection (id: 0):
undefined is not an object (evaluating 'RNGeocoder.reverseGeocodeLocation')
http://localhost:8081/index.ios.bundle?platform=ios&dev=true:61745:11
tryCallTwo@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:2626:3
doResolve@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:2781:19
Promise@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:2647:10
reverseGeocodeLocation@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:61743:19
http://localhost:8081/index.ios.bundle?platform=ios&dev=true:15334:34
requireImpl@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:76:17
requireImpl@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:44:30
_require@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:36:19
global code@http://localhost:8081/index.ios.bundle?platform=ios&dev=true:61774:9
)

my code

var RNGeocoder = require('react-native-geocoder');

// Reverse Geocoding
var NY = {
  latitude: 40.7809261,
  longitude: -73.9637594
};

RNGeocoder.reverseGeocodeLocation(NY, (err, data) => {
  if (err) {
    return;
  }

  console.log(data);
});

Is there any setting issue on my setup? I use the newest react native version.

Receiving response in an array

Not sure if this intended or not, but unlike the README, I seem to be getting a response within an array.

[
    { 
        streetName: 'Stockton St',
        subLocality: 'Union Square',
        formattedAddress: '1000 Stockton St, San Francisco, CA  94108, United States',
        feature: '1000 Stockton St',
        adminArea: 'CA',
        position: { lng: -122.4065285, lat: 37.7858515 },
        postalCode: '94108',
        countryCode: 'US',
        subAdminArea: 'San Francisco',
        streetNumber: '1000',
        country: 'United States',
        locality: 'San Francisco' 
    } 
]

Is it possible that there is more than one item in this array?

[DELETED]

[DELETED] Oh sorry, I'm on the wrong github repo. Please delete this issue.

Receiving no Data

Hey there! I am trying to use this module in my Android RN15 Project. Unfortunately i don´t receive any data. It doesn´t give me any error too. So i have no clue where to search for the issue. I tried updating the android/build.gradle from geocoder to RN 15 which didn´t work...
I hope somebody has an idea or maybe experienced similar issues?

(I call this example in my componentDidMount)

Error: Undefined is not an object

I am hitting an error inside the geocodeAddress function in geocoder.js.

I have performed all the necessary steps to add the library to the linker. I have these lines at the top of my index.ios.js file to test:

import Geocoder from 'react-native-geocoder';

console.log(Geocoder.geocodeAddress("London")['formattedAddress']);

I am seeing this error as soon as I load up the app in the simulator:

undefined is not an object (evaulating RNGeocoder.geocodeAddress)

The issue is on line 29 in geocoder.js:

return RNGeocoder.geocodeAddress(address).catch(err => {

I am guessing that RNGeocoder is for some reason undefined. Is there something I am missing? I have installed the npm module, added the libRNGeocoder.a library to the XCode linker...

I tried adding debugging code into geocoder.js but that seemed to just produce a different error; as though the Geocoder module was no longer able to be loaded.

Problem on execute gradlew assembleRelease

Hi guys, how are u?
I started to use react-native-geocoder, but, when I start to create an assembleRelease, I got this error. Someone can help? Thanks a lot.

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not resolve all files for configuration ':react-native-geocoder:lintClassPath'.

Could not find com.android.tools.lint:lint-gradle:26.1.2.
Searched in the following locations:
file:/C:/Users/thoma/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/lint/lint-gradle/26.1.2/lint-gradle-26.1.2.pom
file:/C:/Users/thoma/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/lint/lint-gradle/26.1.2/lint-gradle-26.1.2.jar
file:/C:/Users/thoma/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/lint/lint-gradle/26.1.2/lint-gradle-26.1.2.pom
file:/C:/Users/thoma/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/lint/lint-gradle/26.1.2/lint-gradle-26.1.2.jar
file:/C:/Users/thoma/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/lint/lint-gradle/26.1.2/lint-gradle-26.1.2.pom
file:/C:/Users/thoma/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/lint/lint-gradle/26.1.2/lint-gradle-26.1.2.jar
file:/C:/Users/thoma/.m2/repository/com/android/tools/lint/lint-gradle/26.1.2/lint-gradle-26.1.2.pom
file:/C:/Users/thoma/.m2/repository/com/android/tools/lint/lint-gradle/26.1.2/lint-gradle-26.1.2.jar
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.2/lint-gradle-26.1.2.pom
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle/26.1.2/lint-gradle-26.1.2.jar
file:/C:/Users/thoma/Desktop/Complemento/otrs.ReactNativeAgentApp/node_modules/react-native/android/com/android/tools/lint/lint-gradle/26.1.2/lint-gradle-26.1.2.pom
file:/C:/Users/thoma/Desktop/Complemento/otrs.ReactNativeAgentApp/node_modules/react-native/android/com/android/tools/lint/lint-gradle/26.1.2/lint-gradle-26.1.2.jar
Required by:
project :react-native-geocoder

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1m 42s
47 actionable tasks: 4 executed, 43 up-to-date

Language

I get the address in my native language on IOS, can i get it in English ?

Performance issue on iOS

Hello,
I'm trying to render multiple markers on Map. The rendering is very laggy on iOS. However, the same code is comparatively faster on Android.

Please review the code and suggest corrections. Thanks in advance.

Below is the code snippet :

componentWillMount() {
this.getMapsMarker().done();
}

async getMapsMarker() {
let incidenceData = this.props.navigation.state.params;
let identifiers = []
for (var i = 0; i < incidenceData.length; i++) {
let incidenceObject = incidenceData[i];
let address = '';
if (incidenceObject.street) {
address = address + incidenceObject.street + ',';
}
if (incidenceObject.city) {
address = address + incidenceObject.city + ',';
}
if (incidenceObject.country) {
address = address + incidenceObject.country + ',';
}
if (incidenceObject.postalCode) {
address = address + incidenceObject.postalCode;
}
console.log(address)
let latitude = 0;
let longitude = 0;
try {
const res = await Geocoder.geocodeAddress(address)
console.log('pos', i)
console.log('geocode', res.length > 0 ? res[0].position : '')
latitude = res.length > 0 ? res[0].position.lat : 0;
longitude = res.length > 0 ? res[0].position.lng : 0
} catch (err) {
console.log(err)
}
let coordinates = {
latitude,
longitude,
}
incidenceData[i].coordinates = coordinates;

    }
    this.setState({
        mapMarkers: incidenceData,
        identifiers
    })
}

render() {
return (

<MapView
style={styles.map}
onMapReady={this.onMapReady}
ref={(ref) => { this.mapRef = ref }}
style={styles.map}>
{this.state.mapMarkers && this.state.mapMarkers.map((marker, i) => {
return (
<MapView.Marker.Animated
identifier={marker.subject}
key={marker.entity_id}
coordinate={marker.coordinates}
tracksViewChanges={!this.state.initialized}
>
<MapView.Callout onPress={() => {
this.navigateToForms();
}}>

{marker.subject}

</MapView.Callout>
</MapView.Marker.Animated>
)
})}


);
}

Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.