Order in Vietnamese freeFormAddress

QuyenNguyen 21 Reputation points
2020-08-20T01:48:13.367+00:00

I am using rest service in Azure Maps

searchURL.searchAddress(atlas.service.Aborter.timeout(10000), text, {  
      language: 'vi-VN',  
      countrySet: ['VN'],  
      limit: 6  
})  

Currently, streetNumber is behind streetName in freeFormAddress.
18981-annotation-2020-08-20-113746.png
My suggestion: streetNumber must be in front of streetName.

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
587 questions
{count} votes

Accepted answer
  1. AshokPeddakotla-MSFT 27,126 Reputation points
    2020-12-16T17:03:13.267+00:00

    Sorry for the delay in response. As mentioned, I was checking with our product team and it is taking more time than expected to consider this feedback. To help prioritize your feedback, I have created an Uservoice entry. Request you to kindly provide your feedback and upvote for the same. All the feedback shared on these forums will be monitored by the product group responsible for building Azure.


1 additional answer

Sort by: Most helpful
  1. rbrundritt 15,211 Reputation points Microsoft Employee
    2023-03-09T19:14:27.02+00:00

    This looks to be fixed in the V2 Search geocoding service here: https://learn.microsoft.com/en-us/rest/api/maps/search-v2/get-geocoding?tabs=HTTP

    Since this service is still in preview, I don't think it is yet exposed through the web-based Services module, so you would need to use the fetch API and call this REST API directly. Here is a sample:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title></title>
    
        <meta charset="utf-8" />    
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    
        <!-- Add references to the Azure Maps Map control JavaScript and CSS files. -->
        <link href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.css" rel="stylesheet" />
        <script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.js"></script>
    
        <script>
            var map, datasource, popup;
    
            var restGeocodeRequestUrl = 'https://{azMapsDomain}/geocode?api-version=2022-09-01-preview&query={query}&view=Auto';
    
            function GetMap() {
                //Initialize a map instance.
                map = new atlas.Map('myMap', {
                    center: [-122.33, 47.6],
                    zoom: 12,
                    view: 'Auto',
    
                    //Add authentication details for connecting to Azure Maps.
                    authOptions: {
                        authType: 'subscriptionKey',
                        subscriptionKey: '<Your Azure Maps Key>'
                    }
                });
    
                //Wait until the map resources are ready.
                map.events.add('ready', function () {
                    //Create a data source and add it to the map.
                    datasource = new atlas.source.DataSource();
                    map.sources.add(datasource);
    
                    //Add a layer for rendering point data.
                    map.layers.add(new atlas.layer.SymbolLayer(datasource, null, {
    					textOptions: {
    						textField: ['get', 'resultIdx'],
    						offset: [0, -1.2],
                            color: "#ffffff",
                            size: 14
    					}
    				}));
                });
            }
    		
    		function geocode() {
    			//Get the parameters for the query.
                var query = document.getElementById('input').value;
    
                var elm = document.getElementById('languageSelector');
                language = elm.options[elm.selectedIndex].value;
    			
    			//Create the REST request URL.
                var requestUrl = restGeocodeRequestUrl.replace('{query}', encodeURIComponent(query));
    				
    			//Process the request and render the route result on the map.
    			processRequest(requestUrl, language).then(results => {
    				if (results && results.features.length > 0) {
    
    					var html = ['<table><tr><td></td><td>Address</td><td>Latitude</td><td>Longitude</td></tr>'];
    
    					for (var i = 0; i < results.features.length; i++) {
    						var r = results.features[i];
    						r.properties.resultIdx = i + 1;
    						
    						html.push(`<tr><td>${i + 1}</td><td>${r.properties.address.formattedAddress}</td><td>${r.geometry.coordinates[1]}</td><td>${r.geometry.coordinates[0]}</td></tr>`);
    					}
    
    					html.push('</table>');
    
    					document.getElementById('output').innerHTML = html.join('');
    					
    					//Add the data to the data source.
    					datasource.add(results);		
    
    					//Fit the map window to the bounding box around the results.
    					map.setCamera({
    						bounds: atlas.data.BoundingBox.fromData(results),
    						padding: 50
    					});		
    				} else {
    					document.getElementById('output').innerHTML = "No results found.";
    				}
    			});
            }
    
    		//Adds the same Azure Maps auth as the map to the query, and makes the REST API request.
            function processRequest(url, language) {
                //This is a reusable function that sets the Azure Maps platform domain, sings the request, and makes use of any transformRequest set on the map.
                return new Promise((resolve, reject) => {
                    //Replace the domain placeholder to ensure the same Azure Maps cloud is used throughout the app.
                    url = url.replace('{azMapsDomain}', atlas.getDomain());
    
                    //Get the authentication details from the map for use in the request.
                    var requestParams = map.authentication.signRequest({ url: url });
    
                    //Transform the request.
                    var transform = map.getServiceOptions().tranformRequest;
                    if (transform) {
                        requestParams = transform(url);
                    }
    				
    				if(language){
    					requestParams.headers['accept-language'] = language;
    				}
    
                    fetch(requestParams.url, {
                        method: 'GET',
                        mode: 'cors',
                        headers: new Headers(requestParams.headers)
                    })
                        .then(r => r.json(), e => reject(e))
                        .then(r => {
                            resolve(r);
                        }, e => reject(e));
                });
            }		
        </script>
    	<style>
    	html, body {
    		width:100%;
    		height:100%;
    		margin:0;
    		padding: 0;
    	}
    	
    	#myMap{
    		position:relative;
    		width:100%;
    		height:100%;
    	}
    	
    	.searchPanel {
    		position: absolute;
    		top: 10px;
    		left:10px;
    		width: 300px;
    		background-color: white;
    		padding: 10px;
    		border-radius: 10px;
    	}
    	
            table {
                border-collapse: collapse;
            }
    
            table, th, td {
                border: 1px solid black;
            }
    		
    		select { 
    			max-width: 280px;
    		}
    		
    		td {
    			padding: 3px;
    		}	
    	</style>
    </head>
    <body onload="GetMap()">
        <div id="myMap"></div>
    	
    	<div class="searchPanel">
    		Query: <input type="text" id="input" />
    		
    		<br/><br/>
    		Language:
    		<select id="languageSelector">
    			<option value=""></option>
    			<option value="af-ZA">Afrikaans (af-ZA)</option>
    			<option value="ar">Arabic (ar)</option>
    			<option value="eu-ES">Basque (eu-ES)</option>
    			<option value="bg-BG">Bulgarian (bg-BG)</option>
    			<option value="ca-ES">Catalan (Spain) (ca-ES)</option>
    			<option value="zh-CN">Chinese (PRC) (zh-CN)</option>
    			<option value="zh-TW">Chinese (Taiwan) (zh-TW)</option>
    			<option value="cs-CZ">Czech (cs-CZ)</option>
    			<option value="da-DK">Danish (da-DK)</option>
    			<option value="nl-BE">Dutch (Belgium) (nl-BE)</option>
    			<option value="nl-NL">Dutch (nl-NL)</option>
    			<option value="en-AU">English (Australia) (en-AU)</option>
    			<option value="en-NZ">English (New Zealand) (en-NZ)</option>
    			<option value="en-GB">English (Great Britain) (en-GB)</option>
    			<option value="en-US">English (USA) (en-US)</option>
    			<option value="et-EE">Estonian (et-EE)</option>
    			<option value="fi-FI">Finnish (fi-FI)</option>
    			<option value="fr-CA">French (Canada) (fr-CA)</option>
    			<option value="fr-FR">French (fr-FR)</option>
    			<option value="gl-ES">Galician (gl-ES)</option>
    			<option value="de-DE">German (de-DE)</option>
    			<option value="el-GR">Greek (el-GR)</option>
    			<option value="hr-HR">Croatian (hr-HR)</option>
    			<option value="he-IL">Hebrew (he-IL)</option>
    			<option value="hu-HU">Hungarian (hu-HU)</option>
    			<option value="id-ID">Indonesian (id-ID)</option>
    			<option value="it-IT">Italian (it-IT)</option>
    			<option value="kk-KZ">Kazakh (kk-KZ)</option>
    			<option value="lv-LV">Latvian (lv-LV)</option>
    			<option value="lt-LT">Lithuanian (lt-LT)</option>
    			<option value="ms-MY">Malay (ms-MY)</option>
    			<option value="no-NO">Norwegian (no-NO)</option>
    			<option value="pl-PL">Polish (pl-PL)</option>
    			<option value="pt-BR">Portuguese (Brazil) (pt-BR)</option>
    			<option value="pt-PT">Portuguese (Portugal) (pt-PT)</option>
    			<option value="ro-RO">Romanian (ro-RO)</option>
    			<option value="ru-RU">Russian (ru-RU)</option>
    			<option value="sr-RS">Serbian (sr-RS)</option>
    			<option value="sk-SK">Slovak (sk-SK)</option>
    			<option value="sl-SI">Slovenian (sl-SI)</option>
    			<option value="es-ES">Castilian Spanish (es-ES)</option>
    			<option value="es-419">Latin American Spanish (es-419)</option>
    			<option value="sv-SE">Swedish (sv-SE)</option>
    			<option value="th-TH">Thai (th-TH)</option>
    			<option value="tr-TR">Turkish (tr-TR)</option>
    			<option value="uk-UA">Ukranian (uk-UA)</option>
    			<option value="vi-VN">Vietnamese (vi-VN)</option>
    		</select>
    
    		<br/><br/>
    		<input type="button" onClick="geocode()" value="Search" />
    		
    		<br/><br/>
    		<div id="output"></div>
    	</div>
    </body>
    </html>
    

    You should find that it works pretty well even if you don't specify a language.

    0 comments No comments