所以我想做的是,我想在获得用户的纬度和经度后更改地图的中心,下面的代码将使问题更清楚:
<LeafletMap
center={this.state.UserCurrentPosition}
zoom={17}
maxZoom={20}
attributionControl={true}
zoomControl={false}
doubleClickZoom={true}
scrollWheelZoom={true}
dragging={true}
animate={true}
easeLinearity={0.35}
>
<TileLayer url='https://tiles.stadiamaps.com/tiles/alidade_smooth_dark/{z}/{x}/{y}{r}.png'/>
<Marker
position={this.state.UserCurrentPosition}
icon={L.divIcon({
className: 'user-marker',
html: `<div class='icon icon-location'><span class="circle"></span></div>`,
iconSize: [40, 40],
iconAnchor: [24, 24]
})}>
</Marker>
</LeafletMap>
Run Code Online (Sandbox Code Playgroud)
以下是我想要做的:
componentDidMount() {
navigator.geolocation.getCurrentPosition(this.showPosition);
}
showPosition = (position) => {
this.setState({ UserCurrentPosition: [position.coords.latitude, position.coords.longitude] })
}
Run Code Online (Sandbox Code Playgroud)
因此,在我使用setState更改用户的当前位置后,标记的位置会更新,但地图的位置不会更新,所以我想知道我是否做错了什么,或者如何完成。
您好,我正在开发一个 Rest api 端点,用于检索分页的用户列表。在前端,有一些选项可以搜索所有列出的列、按所有列排序以及按名称、状态和创建日期进行过滤。
到目前为止,我已经在用户模型中创建了一个存储库和本地范围,用于搜索、排序和过滤。这是我到目前为止的代码。我对过滤器选项感到困惑。由于用户的呼叫过滤器具有所有三个选项。如何以最优化的方式在 api 中传递这些值?
控制器:
public function index(Request $request)
{
$this->userRepository->getAllUsers($request);
}
Run Code Online (Sandbox Code Playgroud)
存储库功能:
public function getAllUsers($request)
{
// Search Parameter
isset($request->q)? $q = $request->q: $q = null;
// Sort Parameter
if ( isset($request->sortby) && (isset($request->direction)) ) {
$sort[$request->sortby] = $request-> direction;
}
return User::where('type','=','student')
->ofSearch($q)
->ofSort($sort)
->paginate($per_page)
}
Run Code Online (Sandbox Code Playgroud)
模型:
public function scopeOfSearch($query, $q)
{
if ( $q ) {
$query->orWhere('name', 'LIKE', '%' . $q . '%')
->orWhere('school', 'LIKE', '%' . $q . '%')
->orWhere('email', 'LIKE', '%' . …Run Code Online (Sandbox Code Playgroud) 我正在使用Behat进行一些自动化测试,并且已将Mink和其Goutte驱动程序添加在一起。我正在使用最新版本的Behat and Mink。
我已经将Mink扩展添加到Feature Context文件中,并且当我运行一个简单的功能时它可以工作:
Feature:...
Scenario: See A Blog Post
Given I am on the homepage
And I follow "login"
Then I should be on "/login"
And I should see "Login"
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试下一步并尝试填写一些字段时:
And I fill in "username" with "admin"
Run Code Online (Sandbox Code Playgroud)
用户名:
<input class="input-field" type="text" id="username"/>
我收到以下错误:
Malformed field path "" (InvalidArgumentException)
Run Code Online (Sandbox Code Playgroud)
任何帮助都感激不尽,
谢谢!