嗨,我有一些角度/引导代码并试图平移到位置。我认为问题出在 GoogleMapsAPI Wrapper 的不同实例中。顺便提一句。缩放和打印圆圈也不起作用。
constructor(private _service: MapService,
private route: ActivatedRoute,
private wrapper: GoogleMapsAPIWrapper) {
}
show(measurement: MeasurementDTO) {
const latlng = new google.maps.LatLng(measurement.latLng.lat, measurement.latLng.lng());
console.log(latlng.lat);
this.map.panTo(latlng);
}
Run Code Online (Sandbox Code Playgroud)
和这里的部分观点。测量来自表,但我认为它是无用的信息。
<agm-map style="height: 600px" [latitude]="1" [longitude]="1" [usePanning]="true">
<agm-marker-cluster [imagePath]="'https://googlemaps.github.io/js-marker-clusterer/images/m'">
<agm-marker
*ngFor="let measurement of measurements"
[latitude]="measurement.latLng.lat"
[longitude]="measurement.latLng.lng">
</agm-marker>
</agm-marker-cluster>
</agm-map>
<button (click)="show(measurement)">Show</button>
Run Code Online (Sandbox Code Playgroud)
2018 年 12 月 6 日更新
我通过在组件中添加地图来解决这个问题:
map: any;
setMap(map) {
console.log(map);
this.map = map;
}
Run Code Online (Sandbox Code Playgroud)
这个 onReady 在 html 中:
<agm-map #mapka style="height: 600px" [latitude]="52.279986" [longitude]="17.35229389999995" [usePanning]="true"
(mapReady)="setMap($event)">
Run Code Online (Sandbox Code Playgroud) 嗨,我将基于同一张表更新行。将“数据”列复制到数据为“”(空)的每一行。这行中的“键”是相同的。
id |data |key
----|-----|-----
1 | xyz |key1
----|-----|-----
2 | "" |key1
Run Code Online (Sandbox Code Playgroud)
我已经尝试过类似的方法,但是“关系a不存在”:
UPDATE a
SET a.data = b.data
FROM table a
INNER JOIN table b
ON (a.key = b.key)
WHERE b.data != '""'
Run Code Online (Sandbox Code Playgroud) 我正在尝试将表单传递给控制器,但对象为空(看起来像从默认构造函数而不是从表单获取值)。而且不知道为什么@Valid不起作用。
码:
终点
@PostMapping("/add")
fun addDevice(@Valid @ModelAttribute device: Device, model: ModelMap): ModelAndView {
deviceRepository.save(device)
return ModelAndView("redirect:/devices/all", model)
}
Run Code Online (Sandbox Code Playgroud)
实体:
@Entity
data class Device(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Int? = null,
@NotNull
val name: String? = "",
@Min(10)
@Max(30)
val price: Int? = null,
@Size(min = 8)
val secretPhrase: String? = ""
) : Serializable
Run Code Online (Sandbox Code Playgroud)
形成
<h1>Add Device</h1>
<!--/*@thymesVar id="device" type="com.example.demo.Device"*/-->
<form action="#" th:action="@{/devices/add}" th:object="${device}" th:method="post">
<div class="col-md-12">
<label>Name Cannot Be Null</label>
<input type="text" minlength="1" th:field="*{name}"></input>
</div> …Run Code Online (Sandbox Code Playgroud)