0.2.0 • Published 6 years ago

react-google-geocoder v0.2.0

Weekly downloads
10
License
Apache-2.0
Repository
github
Last release
6 years ago

react-google-geocoder

License

Copyright (c) 2014-2018 Mike Baranski http://www.mikeski.net

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

react-google-geocoder gives you a text input that allows input validation and geo-location of an address via the Google Geo Location API.

If there are multiple results returned, they are displayed as a list and one can be selected. Once a unique address is located, the component will call a callback with all of the available address information.

See the demo https://mikebski.github.io/react-google-geocoder-demo/

Installation

Install using NPM:

npm install react-google-geocoder --save

You need to get a Google API credential that has GeoCoding enabled. See https://developers.google.com/maps/documentation/geocoding/get-api-key for information on how to get a key.

Note on Credential

For local development with an npm server, for some reason this setup requires a "server" key instead of a credential that is restricted by referrer. If you get errors about needing server credentials without referrer restrictions, generate a new server credential.

Usage

Minimal usage is something like this:

<GeoCoder apiKey="REPLACE_WITY_YOUR_GOOGLE_API_KEY"/>

See the Options below for all available options

Options

PropertyTypeDefault ValueDescription
apiKeyPropTypes.string.isRequiredNoneYour Google API key
searchButtonLabelPropTypes.stringSearchLabel for "Search" button
resetButtonLabelPropTypes.stringResetLabel for "Reset" button
selectButtonLabelPropTypes.stringSelectLabel for "Select" button
acceptButtonLabelPropTypes.stringAcceptLabel for "Accept" button
searchButtonClassPropTypes.stringgeo-code-button geo-code-search-buttonCSS class for "Search" button
resetButtonClassPropTypes.stringgeo-code-button geo-code-reset-buttonCSS class for "Reset" button
selectButtonClassPropTypes.stringgeo-code-button geo-code-select-buttonCSS class for "Select" button
acceptButtonClassPropTypes.stringgeo-code-button geo-code-accept-buttonCSS class for "Accept" button
errorMessagePropTypes.stringThere was an errorError message text
errorMessageClassPropTypes.stringgeo-code-errorCSS class for error message
formTitlePropTypes.stringSearch for AddressTitle of form
showFormTitlePropTypes.booltrueShould show form title?
formClassPropTypes.stringgeo-code-formCSS class for form
tableClassPropTypes.stringgeo-code-tableCSS class for address list table
fieldLabelPropTypes.stringAddressLabel for address field
inputLabelWrapperClassPropTypes.stringgeo-code-input-and-labelCSS class for input and label wrapper
formButtonWrapperClassPropTypes.stringgeo-code-form-button-wrapperCSS class for wrapper for form buttons
inputClassPropTypes.stringgeo-code-inputCSS class for input
labelClassPropTypes.stringgeo-code-labelCSS class for label
onAddressAcceptPropTypes.func(value) => alert("Accepted: " + JSON.stringify(value))Method to call when "Accept" is clicked, this gets passed the address information
inputPropTypes.elementGeoCoderInputInput to use for the form
searchButtonPropTypes.elementGeoCoderSearchButtonSearch button to use for the form
inputPropTypes.elementGeoCoderInputInput to use for the form, see the demo page for how to do this
searchButtonPropTypes.elementGeoCoderSearchButtonButton to use for search
resetButtonPropTypes.elementGeoCoderResetButtonButton to use for reset
acceptButtonPropTypes.elementGeoCoderAcceptButtonButton to use for accept
selectButtonPropTypes.elementGeoCoderSelectButtonButton to use for select

Help

Create an issue here for help

0.2.0

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago