question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to place the autocomplete on Map

See original GitHub issue

I am trying to build the autocomplete on top of a map, but the search box keeps pushing the map down, how can i overlay the search results on the map ?

    <GooglePlacesAutocomplete
                    listViewDisplayed='true'
                    placeholder='Search'
                    minLength={1} // minimum length of text to search
                    autoFocus={false}
                    fetchDetails={true}
                    onPress={(data, details = null) => { // 'details' is provided when fetchDetails = true
                        this.setState({
                            latitude: details.geometry.location.lat,
                            longitude: details.geometry.location.lng, latitudeDelta: 0.3, longitudeDelta: 0.3
                        });
                    }}
                    getDefaultValue={() => {
                        return ''; // text input default value
                    }}
                    query={{
                        // available options: https://developers.google.com/places/web-service/autocomplete
                        key: key
                        language: 'ar', // language of the results
                        types: 'address', // default: 'geocode'
                    }}
                    styles={{
                        description: {
                            fontWeight: 'bold',
                            textAlign: 'right'
                        },
                        predefinedPlacesDescription: {
                            color: '#1faadb',
                        },
                    }}
                    currentLocation={false} // Will add a 'Current location' button at the top of the predefined places list
                    currentLocationLabel="Current location"
                    nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
                    GoogleReverseGeocodingQuery={{
                        // available options for GoogleReverseGeocoding API : https://developers.google.com/maps/documentation/geocoding/intro
                    }}
                    GooglePlacesSearchQuery={{
                        // available options for GooglePlacesSearch API : https://developers.google.com/places/web-service/search
                        rankby: 'distance',
                        types: 'food',
                    }}
                    filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} // filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities
                    predefinedPlacesAlwaysVisible={true}
                />

                <MapView
                    region={this.getMapRegion()}
                    style={styles.map}
                    // onPress={() => alert('hello')}
                    provider={PROVIDER_GOOGLE}
                    mapType="standard"
                    onRegionChangeComplete={(region) => this.setState({
                        latitude: region.latitude, longitude: region.longitude,
                        latitudeDelta: region.latitudeDelta, longitudeDelta: region.longitudeDelta
                    })}
                    showsCompass={true}
                    showsBuildings={true}
                    showsTraffic={true}
                    showsIndoors={true}
                >
                    <MapView.Marker
                        coordinate={this.getMapRegion2()} />
                    <Image

                        style={{
                            resizeMode: 'contain',
                            left: '50%',
                            marginLeft: -24,
                            marginTop: -48,
                            height: 60, width: 60,
                            top: '50%'
                        }} source={require('../../assets/fake-marker.png')} />
                </MapView>

50550819_347618482500155_1182095215993815040_n

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:10

github_iconTop GitHub Comments

5reactions
jaska120commented, Jan 26, 2019

in your styles prop, add:

  container: {
    position: 'absolute',
    zIndex: 9999,
    width: '100%'
  }
3reactions
lyudadcommented, Aug 22, 2019

But select items on Map not work

Read more comments on GitHub >

github_iconTop Results From Across the Web

Place Autocomplete | Maps JavaScript API - Google Developers
The Place Autocomplete sample demonstrates how to use the Place Autocomplete ... Bind the map's bounds (viewport) property to the autocomplete object,
Read more >
Google places autocomplete implementation: A step by step ...
You can use autocomplete to emulate the type-ahead search functionality of the Google Maps search box in your applications. When a user begins...
Read more >
How to add Google Maps Autocomplete search box?
Use Google Maps JavaScript API with places library to implement Google Maps Autocomplete search box in the webpage. HTML
Read more >
How to Use Places Autocomplete Google API - W3docs
Google autocomplete can give us cities, countries, places, and anything else. It's instrumental in website registrations, drawing on the map.
Read more >
Google Place Autocomplete - Ride
Add google maps places javascript by adding the following script to your webpage, be sure to fill in your API key. To get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found