Skip to content

Commit 4f91361

Browse files
authored
Fix Bugs , Update Description of Fill Address Form Sample
1 parent df9b45c commit 4f91361

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

Samples/REST Services/Fill Address Form with Autocomplete/Fill Address Form with Autocomplete.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
<link rel="shortcut icon" href="/favicon.ico"/>
88

99
<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." />
1111
<meta name="keywords" content="Microsoft maps, map, gis, API, SDK, search, geocoding, geocode, autocomplete, autosuggest, jquery" />
1212
<meta name="author" content="Microsoft Azure Maps" /><meta name="version" content="1.0" />
1313
<meta name="screenshot" content="screenshot.jpg" />
1414

1515
<!-- Load JQuery UI -->
1616
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
1717

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>
2020

2121
<!-- Add references to the Azure Maps Map control JavaScript and CSS files. -->
2222
<link href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css" rel="stylesheet" />
@@ -28,7 +28,7 @@
2828

2929
var token;
3030

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}';
3232

3333
async function PageLoaded() {
3434
//Retrieve a SAS token if there isn't one currently available.
@@ -44,7 +44,6 @@
4444
//Create a URL to the Azure Maps search service to perform the address search.
4545
var requestUrl = addressGeocodeServiceUrlTemplate.replace('{query}', encodeURIComponent(request.term))
4646
.replace('{coordinates}', '-95.712891,37.09024') // Default set to US center coordinates
47-
.replace('{language}', 'en-US')
4847
.replace('{resultTypeGroups}', 'Address')
4948
.replace('{resultTypes}', 'Address')
5049
.replace('{countryRegion}', 'US')
@@ -71,13 +70,12 @@
7170
var address = selection.properties.address;
7271

7372
//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 || '';
7674
document.getElementById('cityTbx').value = address.locality || '';
7775
document.getElementById('countyTbx').value = address.adminDistricts && address.adminDistricts[1] ? address.adminDistricts[1].name : '';
7876
document.getElementById('stateTbx').value = address.adminDistricts && address.adminDistricts[0] ? address.adminDistricts[0].name : '';
7977
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 : '';
8179
}
8280
}).autocomplete("instance")._renderItem = function (ul, item) {
8381
//Format the displayed suggestion to show the formatted suggestion string.
@@ -165,7 +163,7 @@
165163

166164
<fieldset style="width:calc(100% - 30px);min-width:290px;margin-top:10px;">
167165
<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.
169167
</fieldset>
170168
</body>
171169
</html>

0 commit comments

Comments
 (0)