Coder Social home page Coder Social logo

rameshsyn / react-location-picker Goto Github PK

View Code? Open in Web Editor NEW
47.0 47.0 21.0 323 KB

A react component to pick a location using google maps

Home Page: https://react-location-picker.netlify.app/

License: MIT License

JavaScript 100.00%
google-maps location-picker react-location-picker

react-location-picker's Introduction

πŸ‘‹ Hi there, I'm Ramesh Syangtan

I'm front-end developer from Kathmandu, Nepal.

πŸ“« How to reach me:

Ramesh's GitHub stats

react-location-picker's People

Contributors

altenorjr avatar dependabot[bot] avatar matty234 avatar rameshsyn avatar whizsid 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

Watchers

 avatar  avatar

react-location-picker's Issues

Map and marker's place doesn't move when the lat,long state is changed by another component.

When using only handleLocationChange, it works fine.

this.state = {
address: 'Kala Pattar Ascent Trail, Khumjung 56000, Nepal',
position: {
lat: 0,
lng: 0
}

handleLocationChange({ position, address, places }) {
this.setState({ position, address });
}

but when it comes to set the states by another component, map marker and map doens't move. I can set the states without any problem but i need to change map markers place when i set the new lat,long.

My other component is below:
onSuggestSelect(suggest) {
let newLat = suggest.location.lat;
let newLng = suggest.location.lng;
let newAddress = suggest.label;
let newProperties = {
position: {
lat: newLat,
lng: newLng
},
address: address,
places: null
};

this.handleLocationChange(newProperties);

}

Can any body have an idea about how can i change the map marker's place?

InvalidValueError thrown

Hi
I am using this component in a capacitor webview app. The error is only seen on the Android platform. It happens after a couple of seconds by just moving the map around with a finger. After the error is thrown the app freezes and needs to be restarted.
Any ideas?

User-Agent: Mozilla/5.0 (Linux; Android 8.0.0; SM-G935F Build/R16NW; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.132 Mobile Safari/537.36

The second error in the image is causing the freeze of the app:

image

Cannot set circle picker programmatically after fetch

good day Mr.

i'm trying to display map on an UPDATE PAGE
so i need to get saved position from server then re-locate the cirlcePicker with the new state
for this reason i use fetch in componentDidMount ( also trying componentWillMount )
but map never change the default state ( initial state )

<LocationPicker containerElement={<div style={{height: '100%'}}/>} mapElement={<div style={{height: '400px'}}/>} defaultPosition={this.state.position} onChange={this.handleLocationChange} />

can you help me please ?

The Map's zoom does not get changed when the zoom value changes

When providing the zoom to the component through state, when updating said value, the zoom in the map does not change accordingly.

example code:


this.state = {
      zoom: 10,
};

handleLocationChange = ({ position, address }) => {
       // Set new location
       this.setState({ position, address, zoom: 14 });
 }

<LocationPicker
         containerElement={ <div style={ {height: '100%'} } /> }
         mapElement={ <div style={ {height: '400px'} } /> }
         defaultPosition={this.state.defaultPosition}
         zoom={this.state.zoom}
         radius={-1}
         onChange={this.handleLocationChange}
/>

If you want to update your documentation

I just wrote your class component to a functional component. hereΒ΄s the code

import React, { useState } from "react";
import LocationPicker from 'react-location-picker';


const LocationPickerComponent = () => {

  const defaultPosition = {
    lat: 27.9878,
    lng: 86.9250
  };

  const [location, setLocation] = useState({
    address: "Kala Pattar Ascent Trail, Khumjung 56000, Nepal",
      position: {
         lat: 0,
         lng: 0
    }
  })

  const handleLocationChange = ({ position, address } = location) => {
    setLocation({ position, address });
  }

  React.useEffect(() => {
    handleLocationChange();
  }, [])

  return (
    <>
      <LocationPicker
        containerElement={ <div style={ {height: '100%'} } /> }
        mapElement={ <div style={ {height: '223px'} } /> }
        defaultPosition={defaultPosition}
        onChange={handleLocationChange}
      />
    </>
  )
}

export default LocationPickerComponent;
;

Unhandled promise rejection

Thank you for the component.

When I select a point in the middle of the ocean, I should get, perhaps, an empty string for the address. Instead, in console I get:

Uncaught (in promise) ZERO_RESULTS

Thank you.

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.