|
7 | 7 | <link rel="shortcut icon" href="/favicon.ico"/> |
8 | 8 |
|
9 | 9 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> |
10 | | - <meta name="description" content="This sample shows how to use the Azure Maps Search service with JQuery UI's autocomplete widget which provides address suggestions as the user types and which populates a form with the selected suggestion." /> |
| 10 | + <meta name="description" content="This sample shows how to use the Azure Maps Search Geocoding Autocomplete service with JQuery UI's autocomplete widget which provides address suggestions as the user types and which populates a form with the selected suggestion." /> |
11 | 11 | <meta name="keywords" content="Microsoft maps, map, gis, API, SDK, search, geocoding, geocode, autocomplete, autosuggest, jquery" /> |
12 | 12 | <meta name="author" content="Microsoft Azure Maps" /><meta name="version" content="1.0" /> |
13 | 13 | <meta name="screenshot" content="screenshot.jpg" /> |
14 | 14 |
|
15 | 15 | <!-- Load JQuery UI --> |
16 | 16 | <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css"> |
17 | 17 |
|
18 | | - <script src="https://code.jquery.com/jquery-1.12.4.js"></script> |
19 | | - <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> |
| 18 | + <script src="https://code.jquery.com/jquery-3.7.1.js"></script> |
| 19 | + <script src="https://code.jquery.com/ui/1.14.1/jquery-ui.js"></script> |
20 | 20 |
|
21 | 21 | <!-- Add references to the Azure Maps Map control JavaScript and CSS files. --> |
22 | 22 | <link href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css" rel="stylesheet" /> |
|
28 | 28 |
|
29 | 29 | var token; |
30 | 30 |
|
31 | | - var addressGeocodeServiceUrlTemplate = 'https://atlas.microsoft.com/geocode:autocomplete?api-version=2025-06-01-preview&query={query}&coordinates={coordinates}&language={language}&resultTypeGroups={resultTypeGroups}&resultTypes={resultTypes}&countryRegion={countryRegion}&top={top}'; |
| 31 | + var addressGeocodeServiceUrlTemplate = 'https://atlas.microsoft.com/geocode:autocomplete?api-version=2025-06-01-preview&query={query}&coordinates={coordinates}&resultTypeGroups={resultTypeGroups}&resultTypes={resultTypes}&countryRegion={countryRegion}&top={top}'; |
32 | 32 |
|
33 | 33 | async function PageLoaded() { |
34 | 34 | //Retrieve a SAS token if there isn't one currently available. |
|
44 | 44 | //Create a URL to the Azure Maps search service to perform the address search. |
45 | 45 | var requestUrl = addressGeocodeServiceUrlTemplate.replace('{query}', encodeURIComponent(request.term)) |
46 | 46 | .replace('{coordinates}', '-95.712891,37.09024') // Default set to US center coordinates |
47 | | - .replace('{language}', 'en-US') |
48 | 47 | .replace('{resultTypeGroups}', 'Address') |
49 | 48 | .replace('{resultTypes}', 'Address') |
50 | 49 | .replace('{countryRegion}', 'US') |
|
71 | 70 | var address = selection.properties.address; |
72 | 71 |
|
73 | 72 | //Populate the address textbox values - mapping new API structure to old fields |
74 | | - document.getElementById('addressLineTbx').value = address.addressLine || |
75 | | - ((address.streetNumber ? (address.streetNumber + ' ') : '') + (address.streetName || '')); |
| 73 | + document.getElementById('addressLineTbx').value = `${address.streetNumber} ${address.streetName}`.trim() || address.addressLine || ''; |
76 | 74 | document.getElementById('cityTbx').value = address.locality || ''; |
77 | 75 | document.getElementById('countyTbx').value = address.adminDistricts && address.adminDistricts[1] ? address.adminDistricts[1].name : ''; |
78 | 76 | document.getElementById('stateTbx').value = address.adminDistricts && address.adminDistricts[0] ? address.adminDistricts[0].name : ''; |
79 | 77 | document.getElementById('postalCodeTbx').value = address.postalCode || ''; |
80 | | - document.getElementById('countryTbx').value = address.countryRegion ? address.countryRegion.ISO : ''; |
| 78 | + document.getElementById('countryTbx').value = address.countryRegions ? address.countryRegions.name : ''; |
81 | 79 | } |
82 | 80 | }).autocomplete("instance")._renderItem = function (ul, item) { |
83 | 81 | //Format the displayed suggestion to show the formatted suggestion string. |
|
165 | 163 |
|
166 | 164 | <fieldset style="width:calc(100% - 30px);min-width:290px;margin-top:10px;"> |
167 | 165 | <legend>Fill Address Form with Autocomplete</legend> |
168 | | - This sample shows how to use the Azure Maps Search service with <a href="https://jqueryui.com/autocomplete/">JQuery UI's autocomplete widget</a> which provides address suggestions as the user types and which populates a form with the selected suggestion. |
| 166 | + This sample shows how to use the Azure Maps Search Geocoding Autocomplete service with <a href="https://jqueryui.com/autocomplete/">JQuery UI's autocomplete widget</a> which provides address suggestions as the user types and which populates a form with the selected suggestion. |
169 | 167 | </fieldset> |
170 | 168 | </body> |
171 | 169 | </html> |
0 commit comments