å°ç空éã¢ããªã±ãŒã·ã§ã³ã¯ãã€ã³ã¿ã©ã¯ãã£ããªå°å³ããäœçœ®æ
å ±ãµãŒãã¹ãŸã§ãç§ãã¡ã®æ¥åžžçæŽ»ã«æ¬ ãããªããã®ãšãªã£ãŠããŸãããã®ãããªã¢ããªã±ãŒã·ã§ã³ã®éèŠãé«ãŸãäžãéçºè
ã¯ä¿¡é Œæ§ã®é«ãå°ç空éãœãªã¥ãŒã·ã§ã³ãæ§ç¯ããããã®åŒ·åã§å®å
šãªããŒã«ãå¿
èŠãšããŠããŸããAmazon Web Services (AWS) ã¯æå
端ã®ãµãŒãã¹ãæäŸãããŠãããæè¿ã§ã¯ Amazon Location Service ã® API ããŒãšèªèšŒãã«ããŒãçºè¡šããå°ç空éã¢ããªéçºè
ã«ãšããµã€ãã£ã³ã°ãªæ©äŒããããããŸãããæ¬èšäºã§ã¯ã API ã㌠ã Amazon Location Service Auth Helper Library ã Amazon Location Service Data Types Converter Library ãæŽ»çšããŠãæ©èœè±å¯ãªå°ç空éã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããæ¹æ³ã玹ä»ããŸãã Amazon Location Service ã®æ°ãããªãªãŒã¹ æè¡çãªè©³çްã«å
¥ãåã«ã Amazon Location Service ã®ææ°ã®æ©èœæ¡åŒµã«ã€ããŠç°¡åã«èª¬æããŸããAmazon Location Service ã¯æè¿ãéçºè
ã Amazon Location Service API ã«å®å
šã«ã¢ã¯ã»ã¹ããããã®è¿œå ãªãã·ã§ã³ãæäŸãã API ããŒãçºè¡šããŸãããAPI ããŒãå©çšããããšã§ãå°ç空éããŒã¿ããµãŒãã¹ãžã®ã¢ã¯ã»ã¹ãå¶åŸ¡ãããããªããèš±å¯ããããŠãŒã¶ãŒã®ã¿ãã¢ããªã±ãŒã·ã§ã³ãšããåãã§ããããã«ãªããããå¹
åºãã¢ããªã±ãŒã·ã§ã³ãããŒã«ãžã®ã¢ã¯ã»ã¹ãå¯èœã«ãªããŸãã ããã«ã Amazon Location Service Auth Helper Library ããªãªãŒã¹ããŸãããããã¯ãéçºè
ã®èªèšŒãšã¯ã¹ããªãšã³ã¹ãåçåããããã®è²ŽéãªãªãœãŒã¹ã§ãããã®ã©ã€ãã©ãªã¯ã Amazon Location Service ã®èªèšŒã®ãŠãŒã¹ã±ãŒã¹ãåçåããããã«èšèšãããŠãããããŒã¿ã®ä¿è·ãšéçºè
ã®ã¹ã ãŒãºãªäœéšãä¿èšŒããŸãã API ããŒã¯ãAPI ãžã®èªèšŒãšã¢ã¯ã»ã¹å¶åŸ¡ã«äœ¿çšãããäžæã®èå¥åã§ãããã®æ©èœã䜿çšããããšã§ãç¹å®ã®ãã¡ã€ã³ãç¹å®ã® Amazon Location Service ãªãœãŒã¹ãžã®ã¢ã¯ã»ã¹ãå¶éãããªã©ããã现ããªã¬ãã«ã§ã¢ã¯ã»ã¹ã管çããããšãã§ããŸãã ãã®æ©èœã¯ãã»ãã¥ãªãã£ã匷åããã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãåäžãããããã«èšèšãããŠããŸããAmazon Location Service API ããŒã¯ãã¢ããªã±ãŒã·ã§ã³ã®ãŠãŒã¶ãŒã«å¯ŸããŠç¹å®ã®ã¢ã¯ã·ã§ã³ãžã®èªã¿åãå°çšã¢ã¯ã»ã¹ãå¯èœã«ããŸããã¢ããªã±ãŒã·ã§ã³ã®ããã³ããšã³ãã«ããŒãåã蟌ãããšã§ãä»ã®èªèšŒæ¹æ³ã«é¢é£ããè€æ°ã®åŒã³åºããåé€ããåŸ
ã¡æéãæ¹åããããšãã§ããŸãããã®ã¢ãããŒã㯠API ã®äœ¿çšç¶æ³ãç£èŠããã¯ã©ãŒã¿ãšããŒã®ããŒããŒã·ã§ã³ã䜿çšããŠããªãœãŒã¹ã®æ¶è²»ã管çããä¹±çšãé²ãããšãå¯èœã«ããŸããAPI ããŒæ©èœã¯ Amazon Location Service Auth Help Library ã«çµ±åããããã¬ãŒã¹ãã«ãŒãã®æ©èœãžã®ã¢ã¯ã»ã¹ç®¡çãããç°¡åã«ãªããŸããã æ¬èšäºã§ã¯ãAPI ããŒãšæ°ãã Auth Helper Library ã®æ©èœããã¢ã³ã¹ãã¬ãŒã·ã§ã³ããå°ç空éã¢ããªã±ãŒã·ã§ã³ã®æ§ç¯ããã»ã¹ã玹ä»ããŸãã APIããŒã®äœæ API ããŒãäœæããåã«ã Amazon Location ãªãœãŒã¹ãäœæããŸãã ããã ã ãã¬ãŒã¹ ã ã«ãŒã ã®ã¬ã€ãã«åŸã£ãŠãæ¬èšäºã§äœ¿çšãããªãœãŒã¹ãäœæããŸããAmazon Location ãªãœãŒã¹ã®äœæäžã«ãåãªãœãŒã¹ã® API ããŒãèšå®ããããããã³ããã衚瀺ãããããšã«æ³šæããŠãã ãããAPI ããŒãäœæããŠãããªãœãŒã¹ããªã³ã¯ããã®ã§ããã®èšå®ã¹ãããã¯çç¥ã§ããŸãã Amazon Location ãªãœãŒã¹ãäœæããããAPI ããŒãäœæããŸããä»åã¯ããããããã¬ãŒã¹ãã«ãŒã ã§äœ¿çšã§ãã 1 ã€ã® API ããŒãäœæããŸãã Amazon Location ã³ã³ãœãŒã«ã«ç§»åãã API Keys ãéžæããŸãã ããã§ Create API key ãéžæããŸãã API ããŒã«ååãä»ããåã®ã¹ãããã§äœæãããªãœãŒã¹ãéžæããŸãã æ¬¡ã«ãæš©éãšãã®ä»ã® API ããŒèšå®ãªãã·ã§ã³ãå®çŸ©ããŸãã ããŒãã¢ã¯ã»ã¹ã§ããèªã¿åãå°çšã® API ã¢ã¯ã·ã§ã³ãå®çŸ©ããããšãã§ããŸããä»åã®ã±ãŒã¹ã§ã¯ã Amazon Location Service ã®äž»èŠãªæ©èœãå©çšã§ããããã«ããããããã¬ãŒã¹ãã«ãŒã API å
ã®ç¹å®ã®ãªãœãŒã¹ãžã®ã¢ã¯ã»ã¹ãèš±å¯ããŸãããããã®ãªãœãŒã¹ã«ã¯é¢é£ã³ã¹ãããããããã䜿çšéã®æ¥å¢ãç£èŠããããã«èª²éã¢ã©ãŒããèšå®ãã宿çãªããŒããŒããŒã·ã§ã³ããã»ã¹ã®äžç°ãšããŠAPI ããŒã®æå¹æéãèšå®ããããšããå§ãããŸãã æåŸã«ãç¹å®ã®ãã¡ã€ã³ã§äœ¿çšããããã« API ããŒãããã¯ããŠã³ãããå Žåã¯ãããŒãæå¹ãª URL ãå¶éãã Referer ãã¡ã€ã³ãèšå®ããããšãã§ããŸãã ããã§ã Create API key ãéžæã㊠API ããŒãäœæããŸãã Show API key value ãéžæãããšãAPI ããŒã衚瀺ãããŸãã ããã§ API Key ãäœæã§ããã®ã§ãã¢ããªã±ãŒã·ã§ã³ã§ API ããŒã䜿ãå§ããããšãåºæ¥ãŸãããããã®ãã¢ã³ãŒãã§ã¯ãAPI ããŒã倿°ãšããŠããŒãã³ãŒãããŠããŸããæ¬çªç°å¢ã«ãããã€ããå Žåã¯ãReferrer ãªã©ã®ã»ãã¥ãªãã£æ©èœã䜿çšããããšã«å ããŠãã¢ããªã±ãŒã·ã§ã³ã®èªèšŒæ
å ±ãä¿åã»ååŸããããã« AWS Secrets Manager ã䜿çšããããšãæšå¥šããŸãã API ããŒã䜿ã£ããããã¢ããªã±ãŒã·ã§ã³ã®æ§ç¯ æ¬èšäºã§ã¯ãå°å³ãšæ€çŽ¢ããã¯ã¹ãå«ãã·ã³ãã«ãªãã¢ãæ§ç¯ããŸãã人æ°ã®ãã MapLibre GL JS ã¬ã³ããªã³ã°ã©ã€ãã©ãªã䜿ã£ãŠå°å³ã衚瀺ããããšããå§ããŸããMapLibre ã¯ã¹ã¿ã€ã« URL ã®æäŸããµããŒãããŠããã®ã§ãAuth Helper Library ã䜿çšããå¿
èŠã¯ãªããAPI ãšã³ããã€ã³ããçŽæ¥èšå®ããããšãã§ããŸãã ãŸã index.html ãã¡ã€ã«ãäœæãã region ãš apiKey ã«å©çšãããªãŒãžã§ã³ãš API ããŒãã mapName ã«ã¯åã®ã¹ãããã§äœæããããããªãœãŒã¹ã«çœ®ãæããŠä»¥äžã®å
容ã远å ããŸãã <!-- index.html --> <!-- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. --> <!-- SPDX-License-Identifier: MIT-0 --> <html> <head> <link href="https://unpkg.com/maplibre-gl@3/dist/maplibre-gl.css" rel="stylesheet" /> <style> body { margin: 0; } #map { height: 100vh; } </style> </head> <body> <!-- Map container --> <div id="map" /> <!-- JavaScript dependencies --> <script src="https://unpkg.com/maplibre-gl@3"></script> <script> const apiKey = "<Your API Key>"; // API key const region = "<Your Region>"; // Region const mapName = "<Your Map Resource>"; // Map name // URL for style descriptor const style = `https://maps.geo.${region}.amazonaws.com/maps/v0/maps/${mapName}/style-descriptor?key=${apiKey}`; // Initialize the map const map = new maplibregl.Map({ container: "map", style, center: [-123.1187, 49.2819], zoom: 11, }); map.addControl(new maplibregl.NavigationControl(), "top-left"); </script> </body> </html> ããã index.html ãšããŠä¿åãããã©ãŠã¶ã§éããŠãã ãããããªãã£ãã·ã¥ã³ãã³ãã¢å·ãã³ã¯ãŒããŒã®å°å³ã衚瀺ãããã¯ãã§ãã å°å³ã衚瀺ã§ããããæ¬¡ã«ã¢ããªã±ãŒã·ã§ã³ã«äœçœ®æ€çŽ¢ãŠã£ãžã§ããã远å ããŸãã å°å³ã«äœçœ®æ
å ±æ€çŽ¢ããã¯ã¹ã远å ãã æ€çŽ¢ããã¯ã¹ã«ã¯ã Amazon Location Service ãã¬ãŒã¹ã€ã³ããã¯ã¹ ã䜿çšããŸãããã¬ãŒã¹ã€ã³ããã¯ã¹ã䜿ããšããžãªã³ãŒãã£ã³ã°/ãªããŒã¹ãžãªã³ãŒãã£ã³ã°ãã§ããŸãããã®äŸã§ã¯ã Amazon Location Service ãš MapLibre ãžãªã³ãŒã㌠ã䜿çšããŸãã ã³ãŒãã¹ãããããã³ããŒãã代ããã«ãã®ã¢ããªã±ãŒã·ã§ã³ãã¯ããŒã³ãããå Žåã¯ããã®ã³ãŒã㯠amazon-location-sample-map-with-geocoder GitHubãªããžããªã§å©çšå¯èœã§ãã ã¢ããªã±ãŒã·ã§ã³ãäœæããããã«ã index.html ãã¡ã€ã«ã«å ã㊠2 ã€ã®ãã¡ã€ã«ãäœæããŸãã ãŸãã index.html ãç·šéããŠããããåé€ããäŸåé¢ä¿ãããŠã³ããŒãããŸãã <!DOCTYPE html> <!-- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. --> <!-- SPDX-License-Identifier: MIT-0 --> <html> <head> <meta charset="utf-8"> <title>Basic Map with Geocoder</title> <!-- Styles --> <link href="https://unpkg.com/maplibre-gl@3/dist/maplibre-gl.css" rel="stylesheet" /> <style> body { margin: 0; } #map { height: 100vh; } </style> </head> <body> <main> <div id="map"></div> </main> <!-- JavaScript dependencies --> <script src="https://unpkg.com/maplibre-gl@3"></script> <script src="https://unpkg.com/@aws/amazon-location-client@1/dist/amazonLocationClient.js"></script> <script src="https://unpkg.com/@aws/amazon-location-utilities-auth-helper@1/dist/amazonLocationAuthHelper.js"></script> <!-- Load the `maplibre-gl-geocoder` plugin. --> <script src="https://unpkg.com/@maplibre/maplibre-gl-geocoder@1/dist/maplibre-gl-geocoder.min.js"></script> <link rel="stylesheet" href="https://unpkg.com/@maplibre/maplibre-gl-geocoder/dist/maplibre-gl-geocoder.css" type="text/css" /> <!-- JavaScript for the app --> <script src="main.js"></script> </body> </html> 次ã«ã main.js ãšããæ°ãããã¡ã€ã«ãäœæãã以äžã®ã³ãŒãã貌ãä»ããŸãã region ãš apiKey ã«å©çšãããªãŒãžã§ã³ãš API ããŒãã mapName ã«ã¯åã®ã¹ãããã§äœæããããããªãœãŒã¹ã«çœ®ãæããŠä»¥äžã®å
容ã远å ããŸãã const { GetPlaceCommand, LocationClient, SearchPlaceIndexForSuggestionsCommand, SearchPlaceIndexForTextCommand } = amazonLocationClient; // Amazon Location Service Resources: const apiKey = "<Amazon Location API key>"; const mapName = "<Amazon Location Map resource name>"; const placeIndex = "<Amazon Location PlaceIndex resource name>"; const region = "<AWS Region, e.g., eu-central-1>"; // Add Geocoder control to the map via callbacks that are called by maplibre-gl-geocoder. // forwardGeocode: required for geocoding (Amazon Location SearchPlaceIndexForText API) // getSuggestions + searchByPlaceId: required for autosugget (Amazon Location SearchPlaceIndexForSuggestions + GetPlace APIs) async function addGeocoder(map, authHelper, client) { const amazonLocationGeocoderApi = { forwardGeocode: async (config) => { try { // Set up command to call SearchPlaceIndexForText API const { Results } = await client.send(new SearchPlaceIndexForTextCommand({ IndexName: placeIndex, Text: config.query })); // Convert the results to Carmen GeoJSON (<link>) to be returned to the MapLibre Geocoder const features = Results.map((result) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: result.Place.Geometry.Point, }, place_name: result.Place.Label, properties: { id: result.Place.PlaceId, }, text: result.Place.Label, place_type: ['place'], center: result.Place.Geometry.Point, })); return { features }; } catch (error) { console.error(`Failed to forwardGeocode with error: ${error}`); } }, getSuggestions: async (config) => { try { // Set up a command to call SearchPlaceIndexForSuggestions API; const { Results } = await client.send(new SearchPlaceIndexForSuggestionsCommand({ IndexName: placeIndex, Text: config.query })); // Iterate over data.Results and return all suggestions and their place ids const suggestions = Results.map((result) => ({ text: result.Text, placeId: result.PlaceId, })); return { suggestions }; } catch (error) { console.error(`Failed to getSuggestions with error: ${error}`); } }, searchByPlaceId: async (config) => { try { // Set up command to call GetPlace API with a place Id of a selected suggestion const { Place } = await client.send(new GetPlaceCommand({ IndexName: placeIndex, PlaceId: config.query, })); const place = { type: 'Feature', geometry: { type: 'Point', coordinates: Place.Geometry.Point, }, place_name: Place.Label, text: Place.Label, center: Place.Geometry.Point, }; return { place }; } catch (error) { console.error(`Failed to searchByPlaceId with error: ${error}`); } }, }; // Add Geocoder control to the map map.addControl(new MaplibreGeocoder(amazonLocationGeocoderApi, { maplibregl, showResultsWhileTyping: true })); } // Initialize a map async function initializeMap() { const map = new maplibregl.Map({ container: 'map', // HTML element ID of map element center: [-123.1187, 49.2819], // Initial map centerpoint zoom: 16, // Initial map zoom style: `https://maps.geo.${region}.amazonaws.com/maps/v0/maps/${mapName}/style-descriptor?key=${apiKey}`, // Defines the appearance of the map and authenticates using an API key }); // Add navigation control to the top left of the map map.addControl(new maplibregl.NavigationControl(), 'top-left'); return map; } async function main() { // Create an authentication helper instance using an API key const authHelper = await amazonLocationAuthHelper.withAPIKey(apiKey); const client = new LocationClient({ region, ...authHelper.getLocationClientConfig(), // Provides configuration required to make requests to Amazon Location }); // Initialize map and add a geocoder to it. const map = await initializeMap(); addGeocoder(map, authHelper, client); } main(); ãã¹ãŠã®ãã¡ã€ã«ãäœæããããã index.html ããã©ãŠã¶ã§éããå³äžã«ããæ€çŽ¢ããã¯ã¹ãããå°å³ãèŠãããšãã§ããŸãã ããã§ãžãªã³ãŒãã£ã³ã°ããã¹ãåºæ¥ãããã«ãªããŸãããç»åã¯ã Amazon Location Service ãã¬ãŒã¹ã€ã³ããã¯ã¹ã®èªåè£å®ãšåæ¹ãžãªã³ãŒãã£ã³ã°æ©èœã詊ããŠã¿ããã®ã§ãã Auth Library ãçè§£ãã ããŠãã¢ããªã±ãŒã·ã§ã³ãäœæããŸãããAmazon Location Service Auth Helper Library ãã©ã®ããã«åäœããã®ããçè§£ããããã«ãã³ãŒãã詳ããèŠãŠãããŸãããã æåã«è¡ãããšã¯ãèªèšŒæ¹æ³ãå®çŸ©ããããšã§ããããã«ã¯ Amazon Cognito Identity Pools ãããã㯠API ããŒã䜿çšããŸãã API ããŒã®å Žåãæ¬¡ã®ããã« Auth ã¡ãœããã䜿çšããŸãã const authHelper = await amazonLocationAuthHelper.withAPIKey(apiKey); Amazon Cognito Identity Pools ã䜿çšããå Žåãæ¬¡ã®ããã«äœ¿çšããŸãã const authHelper = await withIdentityPoolId(identityPoolId); 次ã«ãAmazon Location Service Client ãã€ã³ã¹ã¿ã³ã¹åããéã«ãAuth Helper ãèªã¿èŸŒã¿ãŸããAuth Helper ã¯ãåã®ã¹ãããã§èšå®ããèªèšŒã®ã¿ã€ãã«åºã¥ããŠãã¯ã©ã€ã¢ã³ãã«è¿œå ã®ããããã£ãå«ããŸãã const client = new amazonLocationClient.LocationClient({ region, ...authHelper.getLocationClientConfig(), // Provides configuration required to make requests to Amazon Location }); æåŸã«ãAmazon Location Service API ãåŒã³åºããŸãããã¬ãŒã¹ã€ã³ããã¯ã¹ã䜿ã£ãŠ Seattle, WA ãæ€çŽ¢ãããšãŠãã·ã³ãã«ãªäŸã§ã¯ãAuth Helper ãš Client ã䜿ã£ãŠ SearchPlaceIndexForText API ãåŒã³åºããŸãã <!-- index.html --> <!-- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. --> <!-- SPDX-License-Identifier: MIT-0 --> <html> <head> </head> <body> <pre id="place_index_results" ></pre> <script src="https://unpkg.com/@aws/amazon-location-client@1/dist/amazonLocationClient.js"></script> <script src="https://unpkg.com/@aws/amazon-location-utilities-auth-helper@1/dist/amazonLocationAuthHelper.js"></script> <script> const Key = "<Amazon Location API key>"; // API key const region = "<Amazon Location PlaceIndex resource name>"; // Region const IndexName = "<AWS Region, e.g., eu-central-1>"; async function placeIndexSearch(){ const authHelper = await amazonLocationAuthHelper.withAPIKey(Key); const { LocationClient, SearchPlaceIndexForTextCommand } = amazonLocationClient; // Instantiate the Amazon Location Service Client using the Auth Helper configuration const client = new LocationClient({ region, ...authHelper.getLocationClientConfig() // Provides configuration required to make requests to Amazon Location using either API Keys or Cognito }); // Call the SearchPlaceIndexForText API using the Amazon Location client const data = await client.send(new SearchPlaceIndexForTextCommand({ IndexName, Text: "Seattle, WA", MaxResults: 1, })); document.getElementById("place_index_results").innerHTML = JSON.stringify(data['Results'], null, 4); } placeIndexSearch(Key) </script> </body> </html> ãã®äŸã§ã¯ãçµæã¯ JSON ãšããŠãã©ãŠã¶ã«è¡šç€ºãããŸãã ã芧ã®éããæ°ãã Auth Helper 㯠Amazon Location ãªãœãŒã¹ã®èªå¯èšå®ãããç°¡åã«ããŸãã Python ã§ã®å©çš JavaScript ã«ããããã³ããšã³ãã¢ããªã±ãŒã·ã§ã³ã®æ§ç¯ã«å ããŠãAPI ããŒã¯ Amazon Location SDK ããµããŒããããã¹ãŠã®èšèªã§ãµããŒããããŠããŸããããã¯ãšã³ãã¢ããªã±ãŒã·ã§ã³ã§ API ããŒã䜿çšããããšã§ãã¢ããªã±ãŒã·ã§ã³ããã¹ãããã€ã³ãã©äžã§ IAM ããŒã«ãäžæçãªèªèšŒæ
å ±ãèšå®ããããã«å¿
èŠãªãªãŒããŒããããåæžããããšãã§ããŸããäŸãã°ã次ã®äŸã¯ãã³ãã³ãã©ã€ã³ã§äœæãåãåããAPI ããŒã䜿çšããŠãžãªã³ãŒãã£ã³ã°ããã·ã³ãã«ãª Python ã¹ã¯ãªããã§ããåçŽãª Python ã¢ããªã±ãŒã·ã§ã³ãäœæããã«ã¯ãæ°ãã Python ãã¡ã€ã«ãäœæãã以äžã®ã³ãŒãã貌ãä»ããŸãã #Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #SPDX-License-Identifier: MIT-0 import boto3from botocore import UNSIGNEDfrom botocore.config import Config client = boto3.client("location", region_name='<AWS Region, e.g., eu-central-1>', config=Config(signature_version=UNSIGNED)) text = input() response = client.search_place_index_for_text( IndexName='<Amazon Location PlaceIndex resource name>', Key='<Amazon Location API key>', MaxResults=1, Text=text) print(response['Results']) ã³ãŒããå®è¡ããéãæ€çŽ¢èªãå
¥åããŠãã ããããã®å Žåããã¥ãŒãšãŒã¯ãæ€çŽ¢ããŸãã Enter ãæŒããšãAmazon Location Service ãã¬ãŒã¹ã€ã³ããã¯ã¹ã®æ€çŽ¢çµæã衚瀺ãããŸãã ããŒã¿å倿ã©ã€ãã©ãª Auth Helper Library ã«å ããŠãJavaScript çšã® Amazon Location Utilities â ããŒã¿åã©ã€ãã©ãªããªãªãŒã¹ããŸããããããã®ã©ã€ãã©ãªã¯ãAmazon Location Service API ããã®åºåãäžè¬ç㪠GeoJSON ããŒã¿ãã©ãŒãããã«å€æãããžãªãã§ã³ã¹ã®äœæããã¬ãŒã¹ã€ã³ããã¯ã¹æ€çŽ¢ãªã©ã®ããã«ãããã®ãã©ãŒãããããã®å
¥åãåãåããŸãããã®äŸã§ã¯ããŠãŒã¶ãŒããã®å
¥åãåãåãã Amazon Location Service ãã¬ã€ã¹ã€ã³ããã¯ã¹ãæ€çŽ¢ããçµæã GeoJSON ãã©ãŒãããã§è¿ãéåžžã«ã·ã³ãã«ãªã¢ããªãæ§ç¯ããŸãããããŠããã® ãµã³ãã«ã¢ããªã±ãŒã·ã§ã³ ã䜿ã£ãŠãã€ã³ãã衚瀺ããŸãããŸããæ°ããHTMLãã¡ã€ã«ãéãããªãŒãžã§ã³ããã¬ã€ã¹ã€ã³ããã¯ã¹ãAPI ããŒãå
ã»ã©äœæããå€ã«çœ®ãæããŠã以äžã貌ãä»ããŸãã <!-- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. --> <!-- SPDX-License-Identifier: MIT-0 --> <html> <head> <link href="https://unpkg.com/maplibre-gl@3/dist/maplibre-gl.css" rel="stylesheet" /> <style> body { margin: 0; } #map { height: 100vh; } </style> </head> <pre id="jsonText" ></pre> <body> <div id="map" /> <script src="https://unpkg.com/maplibre-gl@3"></script> <script src="https://unpkg.com/@aws/amazon-location-utilities-auth-helper@1/dist/amazonLocationAuthHelper.js"></script> <script src="https://www.unpkg.com/@aws/amazon-location-utilities-datatypes@1/dist/amazonLocationDataConverter.js"></script> <script src="https://unpkg.com/@aws/amazon-location-client@1/dist/amazonLocationClient.js"></script> <script> async function initializeMap() { const key = "<Amazon Location API key>"; const mapName = "<Amazon Location Map resource name>"; const region = "<AWS Region, e.g., eu-central-1>"; const IndexName = "<Amazon Location PlaceIndex resource name>"; const searchTerm = prompt("Search for a Location"); // Create an authentication helper instance using credentials from Cognito const authHelper = await amazonLocationAuthHelper.withAPIKey(key); const client = new amazonLocationClient.LocationClient({ region, ...authHelper.getLocationClientConfig(), // Provides configuration required to make requests to Amazon Location }); const searchResults = await client.send( new amazonLocationClient.SearchPlaceIndexForTextCommand({ IndexName, Text: searchTerm, MaxResults: 1, }) ); // Initialize the map const map = new maplibregl.Map({ container: "map", // Set the map centerpoint based on the geojson coordinates center: featureCollection.features[0].geometry.coordinates, // Initial zoom level zoom: 14, style: `https://maps.geo.${region}.amazonaws.com/maps/v0/maps/${mapName}/style-descriptor?key=${key}`, }); // Add navigation controls map.addControl(new maplibregl.NavigationControl(), "top-left"); map.on("load", () => { // Convert search results into a GeoJSON FeatureCollection const featureCollection = amazonLocationDataConverter.placeToFeatureCollection(searchResults); // Add a data source containing GeoJSON produced from the Amazon Location Service ãã¬ãŒã¹ã€ã³ããã¯ã¹ output. map.addSource("place-index-results", { type: "geojson", data: featureCollection, }); // Add a new layer to visualize the points. map.addLayer({ id: "place-index-results", type: "circle", source: "place-index-results", paint: { "circle-radius": 8, "circle-color": "#0080ff", }, }); map.on('click', 'place-index-results', (e) => { const coordinates = e.features[0].geometry.coordinates.slice(); const description = JSON.stringify(featureCollection, null, 4);; new maplibregl.Popup() .setLngLat(coordinates) .setHTML(description) .addTo(map); }); }); } initializeMap(); </script> </body> </html> HTML ããŒãžãããŒããããšãæ€çŽ¢ãå
¥åããããã³ããã衚瀺ãããŸãããè¿ãã®åžçºæããããè¡ããããåºãæ€çŽ¢ããŠã¿ãŠãã ãããâOKâ ãã¯ãªãã¯ãããšãå°å³ãšã¢ã€ã³ã³ã衚瀺ãããŸããããŒã«ãŒãã¯ãªãã¯ãããšãããŒã¿å倿ã©ã€ãã©ãªãæäŸãã GeoJSON åºåã衚瀺ãããŸãã ãŸããããŒã¿å倿ã©ã€ãã©ãªãã«ãŒãã£ã³ã°ã«äœ¿ãããšã§ãAmazon Location Service ãæäŸããã«ãŒããéçºè
ãç°¡åã«å°å³äžã«æãããšãã§ããããã®äŸã¯äžèšãšéåžžã«äŒŒãŠããŸãããä»åã¯å
ã«äœæããã«ãŒãèšç®æ©ãå«ã¿ãŸãã ãŸããæ°ãã HTML ãã¡ã€ã«ãéãã region ãš CaluculatorName ã«å©çšãããªãŒãžã§ã³ãšèšç®æ©ããKey ã«å
ã»ã©äœæãã API ããŒã®å€ã«çœ®ãæããŠã以äžã貌ãä»ããŸããã«ãŒããæãããã« DeparturePosition ãš DestinationPosition ãèšå®ããŸãã <!-- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. --> <!-- SPDX-License-Identifier: MIT-0 --> <html> <head> <link href="https://unpkg.com/maplibre-gl/dist/maplibre-gl.css" rel="stylesheet" /> <style> body { margin: 0; } #map { height: 100vh; } </style> </head> <body> <div id="map" /> <script src="https://unpkg.com/maplibre-gl@3"></script> <script src="https://unpkg.com/@aws/amazon-location-utilities-auth-helper@1/dist/amazonLocationAuthHelper.js"></script> <script src="https://www.unpkg.com/@aws/amazon-location-utilities-datatypes@1/dist/amazonLocationDataConverter.js"></script> <script src="https://unpkg.com/@aws/amazon-location-client@1/dist/amazonLocationClient.js"></script> <script> async function initializeMap() { const key = "<Amazon Location API key>"; const mapName = "<Amazon Location Map resource name>"; const region = "<AWS Region, e.g., eu-central-1>"; const IndexName = "<Amazon Location PlaceIndex resource name>"; const CalculatorName = "<Amazon Location Route Calculator resource name>"; const DeparturePosition = "[Departure Longitude, Departure Latitude]" const DestinationPosition = "[Destination Longitude, Destination Latitude]" // Create an authentication helper instance using credentials from Cognito const authHelper = await amazonLocationAuthHelper.withAPIKey(key); const client = new amazonLocationClient.LocationClient({ region, ...authHelper.getLocationClientConfig(), // Provides configuration required to make requests to Amazon Location }); const route = await client.send( new amazonLocationClient.CalculateRouteCommand({ CalculatorName, DeparturePosition, DestinationPosition, IncludeLegGeometry: true, }) ); // Initialize the map const map = new maplibregl.Map({ container: "map", // Set the map centerpoint based on the geojson coordinates center: DeparturePosition, // Initial zoom level zoom: 11, style: `https://maps.geo.${region}.amazonaws.com/maps/v0/maps/${mapName}/style-descriptor?key=${key}`, }); // Add navigation controls map.addControl(new maplibregl.NavigationControl(), "top-left"); map.on("load", () => { // Convert Amazon Location Service route to GeoJSON const featureCollection = amazonLocationDataConverter.routeToFeatureCollection(route); // Add a data source containing GeoJSON produced from the Amazon Location Service ãã¬ãŒã¹ã€ã³ããã¯ã¹ output. map.addSource("route", { type: "geojson", data: featureCollection, }); // Add a new layer to visualize the points. map.addLayer({ id: "route", type: "line", source: "route", layout: { "line-join": "round", "line-cap": "round", }, paint: { "line-color": "#00b0ff", "line-width": 8, }, }); }); } initializeMap(); </script> </body> </html> ãã®ä»ã®ããŒã¿å倿ã«ã€ããŠã¯ãGitHub ã® aws-geospatial/amazon-location-utilities-datatypes-js ãªããžããªã§ããããã®ãŠãŒãã£ãªãã£ã®äœ¿ãæ¹ãæäŸãããŠãããã®ä»ã®å€æã®è©³çްãã芧ãã ããã ã¯ãªãŒã³ã¢ãã 以äžã®ãªã³ã¯ã䜿çšããŠã ããã ã ãã¬ãŒã¹ã€ã³ããã¯ã¹ ã ã«ãŒãèšç® ãªãœãŒã¹ãåé€ããŸããæ¬èšäºã§äœæãã API ããŒãåé€ããã«ã¯ã ãã¡ã ã®æé ã«åŸã£ãŠãã ããã ãŸãšã æ°ãã Amazon Location Service Auth Helper Library ã¯ãAmazon Location Service API ããŒããã³ Amazon Cognito Identity Pools ãšã®ã·ãŒã ã¬ã¹ãªçµ±åãæäŸããããšã§ãå°ç空éã¢ããªã±ãŒã·ã§ã³ã®æ§ç¯ãç°¡çŽ åããŸããAuth Helper Library ã䜿çšããããšã§ãéçºè
ã¯ã¢ããªã±ãŒã·ã§ã³ã§ Amazon Location Service ãããããã¬ãŒã¹ãã«ãŒããšç°¡åã«é£æºããããšãã§ããŸãã ãŸããGeoJSON ã®ãã㪠Amazon Location Service ãšäºææ§ã®ããç°ãªãããŒã¿åéã§å€æããæ©èœãéçºè
ã«æäŸããŸããããããã®ãŠãŒãã£ãªãã£ã䜿ãããšã§ãéçºè
㯠GeoJSON ãåãåã£ãŠãžãªãã§ã³ã¹ãäœæãããããã¬ãŒã¹ã€ã³ããã¯ã¹ããžãªãã§ã³ã¹ãã«ãŒããã GeoJSON åºåãåŸããããããšãã§ããŸãã ããã«ãããå°ç空éã¢ããªã±ãŒã·ã§ã³çšã® MapLibre ãªã©ã®äžè¬çãªã©ã€ãã©ãªã®éçºã容æã«ãªããŸãã ããå€ãã®ãµã³ãã«ã¢ããªã±ãŒã·ã§ã³ã«ã€ããŠã¯ãGitHub ã«ãã¹ããããŠãã aws-geospatial ãªããžããªã蚪åããAmazon Location Service ãæäŸããæ©èœãã€ã³ã¿ã©ã¯ãã£ãã«èŠãããã«ã¯ location.aws.com ãã¢ãµã€ãããã§ãã¯ããŠãã ããã æ¬èšäºã¯ã Build a Geospatial Application with Amazon Location Service API Keys ãã翻蚳ãããã®ã§ãã èè
ã«ã€ã㊠Zach Elliott Zach Elliott ã¯ãAWS ã§ Amazon Location Service ã«ãã©ãŒã«ã¹ãããœãªã¥ãŒã·ã§ã³ã¢ãŒããã¯ããšããŠåããŠããŸãã圌ã¯ãã客æ§ã AWS äžã§å°ç空éãœãªã¥ãŒã·ã§ã³ãæ§ç¯ããã®ãæ¯æŽããããšã«æ
ç±ã泚ãã§ããŸãã圌ã¯ãŸããAWS ã® IoT Subject Matter Expert ã³ãã¥ããã£ã®äžå¡ã§ãããã顧客ããŠããŒã¯ãª IoT ããŒã¹ã®ãœãªã¥ãŒã·ã§ã³ãéçºããã®ãæ¯æŽããã®ã倧奜ãã§ãã Anand Vijayan Anand Vijayan 㯠AWS ã§ Amazon Location Service ã«ãã©ãŒã«ã¹ããã·ãã¢ã»ãããã¯ãã»ãããŒãžã£ãŒãšããŠåããŠãããå°ç空éãã¯ãããžãŒã«è奮ããã¯ã©ãŠãã®ãã¯ãŒã掻çšããŠé¡§å®¢ãè€éãªåé¡ãå€§èŠæš¡ã«è§£æ±ºã§ããããæ¯æŽããããšã«åã³ãæããŠããŸãã圌ã¯ç±å¿ãªå€©æåŠè
ã§ãããããããå®å®ã«åŒ·ãé¢å¿ãæã£ãŠããŸãã Seth Fitzsimmons Seth 㯠Amazon Location Service ããµããŒãããããªã³ã·ãã«ãšã³ãžãã¢ã§ããäœæã«ã¯ã倪平æŽå²žå西éšã®å·ãå±±ã§æ°Žéã³ãããŠããŸãã Oren Weiss Oren Weiss 㯠Amazon Web Service ã§ãœãªã¥ãŒã·ã§ã³ã¢ãŒããã¯ããšããŠåããŠããããã以åã¯ãAmazon Location Service ãå«ãè€æ°ã®ããŒã ã§ãœãããŠã§ã¢éçºãããŒãžã£ãŒãåããŠãããã客æ§ã AWS äžã§é©æ°çã§ã¹ã±ãŒã©ãã«ãã€ã³ã¹ãå¹çã®é«ããœãªã¥ãŒã·ã§ã³ãæ§ç¯ã§ããããæ¯æŽããããšã«æ
ç±ã泚ãã§ããŸãã 翻蚳è
ã«ã€ããŠ çš²ç° å€§éž AWS Japan ã§åãçãã¬ãè¶£å³ã®ãœãªã¥ãŒã·ã§ã³ã¢ãŒããã¯ããæ®æ®µã¯è£œé æ¥ã®ã客æ§ãäžå¿ã«æè¡æ¯æŽãè¡ã£ãŠããŸãã奜ã㪠AWS ãµãŒãã¹ã¯ Amazon Location Service ãš AWS Amplify ã§ãæ¥æ¬ã®ã客æ§åãã« Amazon Location Service ã®è§£èª¬ããã° ãªã©ãå·çããŠããŸãã