如何将google地址lat收件箱设置为输入值?
我可以获取地址、更新和删除任何我想获取的信息.
但如何设置我的输入值呢?
在我的newPostPage.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代码
<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>
我可以获取信息
那么,我想把信息输入值,怎么办呢?我需要添加城市、纬度和纬度,而且它是禁用的.
我认为城市json场是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>