English 中文(简体)
我如何用权角向输入值倾角?
原标题:How do I set google address lat lng to input value?

我如何用权角向输入值倾角?

我可以听到我想要获得信息的话。

但我如何确定我的投入价值?

在我新的PostPage.jsx案中,我使用了这一守则。

const [selectedAddress,setSelectedAddress] = useState();
const [coordinates, setCoordinates] = useState();

<div className="item">
  <label htmlFor="address">Address</label>
  <GoogleAddressSearch
      selectedAddress={(value)=> setSelectedAddress(value)}
      setCoordinates={(value)=> setCoordinates(value)}
/>
</div>

GoogleAddressSearch.jsx code

<GooglePlacesAutocomplete apiKey=process.env.GoogleApiKey 
    selectProps={{
        placeholder:  Search... ,
        isClearable:true,
        className: w-full ,
        onChange:(place) => {
            console.log(place)
            selectedAddress(place)
            geocodeByAddress(place.label)
            .then(result=>getLatLng(result[0]))
            .then(({lat,lng}) => {
                setCoordinates({lat,lng})
            })
        }
    }}/>
    </div>

And I can get the information

“enter

Then, I want to put information to input value, how can I do? I need to put city, lat and lng, also it s disable.

I think the city json field is secondary_text

<div className="item">
  <label htmlFor="city">City</label>
  <input id="city" name="city" type="text" disabled />
</div>
<div className="item">
  <label htmlFor="latitude">Latitude</label>
  <input id="latitude" name="latitude" type="text" disabled />
</div>
<div className="item">
  <label htmlFor="longitude">Longitude</label>
  <input id="longitude" name="longitude" type="text" disabled />
</div>
最佳回答

Modified

const [selectedAddress,setSelectedAddress] = useState();
const [coordinates, setCoordinates] = useState();

to

const [selectedAddress,setSelectedAddress] = useState(  );
const [coordinates, setCoordinates] = useState(  );

添加<代码>const [city, setCity] = useState( )

Then

<input id="city" name="city" type="text" disabled value={city} />
<input id="latitude" name="latitude" type="text" disabled value={coordinates.lat}  />
<input id="latitude" name="latitude" type="text" disabled value={coordinates.lng}  />

function GoogleAddressSearch add setCity

function GoogleAddressSearch({selectedAddress,setCoordinates,setCity})
.
.
.
setCity(place.value.structured_formatting.secondary_text)
..

结 论

<div className="item">
  <label htmlFor="address">Address</label>
  <GoogleAddressSearch
      selectedAddress={(value)=> setSelectedAddress(value)}
      setCoordinates={(value)=> setCoordinates(value)}
      setCity={(value)=>setCity(value)}
/>
</div>

问题回答

暂无回答




相关问题
How to decide the current point reach on google map?

How to decide the current point reach on google map? I have a list of points (pickup points) of a route that I want to show in my google map with polyline. Now i have to get the current location of ...

Topographical or relief data in Map APIs

I was wondering if anyone knew of any map APIs that offer topographical or relief data? I ve had a quick look at Google and Bing APIs, but could find nothing there. Google allow you to view a map as ...

Using maps on Windows Mobile

I m experimenting with maps on different mobile platforms. Getting Google Maps to work on Android was easy, following this tutorial. Getting the same to work on Windows Mobile is a different matter. ...

Adding a custom icon to a google map

I need a hand adding a custom icon to some Google Maps javascript. Code below for your reference: function populateMap() { var map = new GMap2(document.getElementById("map")); map.setCenter(new ...

RSS to KML Overlay

I m want to display my blog as a Google Map overlay (each post contains geotags). How can I dynamically create a KML overlay from an RSS? Or better, how can I create a loop (PHP) that would display ...

开放街道地图管理员

我需要开放Street的标记管理员。 地图,如山角地图。

热门标签