Skip to main content

介紹

透過 mapPlus PlacesService API 中的方法,可以搜尋地圖指定的地點。

開始使用

調用 new mapPlus.PlacesService(map, options),開始使用地圖搜尋 API,以下為參數說明:

  • map (object): 帶入 new mapPlus() 返回的物件。
  • options (object): 選填,可調整地圖搜尋的設定。
參數描述
options.enableMultipleRequests boolean是否能允許同時發送多個請求,預設為 true
const map = await new mapPlus(document.getElementById('map'), {
accessToken: 'get_your_token',
accessKey: 'get_your_key',
style: 'https://kw3dmap.localking.com.tw/openapi/map/kwmap.etxt',
});

const service = new mapPlus.PlacesService(map, {
enableMultipleRequests: true,
});

其他說明

locationBias

locationBias 的參數可使用以下三種方式:

  • 經緯度
  • 以經緯度為中心的半徑範圍(單位:公尺)
  • 矩形區域

經緯度

locationBias: { 
lat: 37.402105,
lng: -122.081974
}

以經緯度為中心的半徑範圍(單位:公尺)

locationBias: { 
radius: 100,
center: {
lat: 37.402105,
lng: -122.081974
}
}

矩形區域

locationBias: { 
north: 37.41,
south: 37.40,
east: -122.08,
west: -122.09
}