[英]How to set marker on center of the screen in google map
我正在使用javascript制作uber或lyft等交通工具的應用程序。 我需要通過屏幕中心獲取地圖位置,我在y = 0和x = 0處有一個標記。
喜歡這張圖片:
用手指移動屏幕並自動注冊新位置,因為標記始終位於屏幕中央。
誰能幫助我? 非常感謝你
您需要的是聆聽地圖的center_changed事件,並獲取中心的經緯度。正如您所說的,標記始終位於地圖的中心。
this.map = new google.maps.Map(this.mapElement.nativeElement);
_this = this;
google.maps.event.addListener(this.map, 'center_changed', function () {
_this.latLngObj = _this.map.getCenter();
console.log('lat long object '+ _this.latLngObj);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.