[英]how do I tell Google Maps JavaScript API v3 to use Finnish (or Swedish) characters?
I try to query LatLong-coordinates from a Finnish address with Google Maps geocoder. 我尝试使用Google Maps地理编码器从芬兰地址查询LatLong坐标。 The aim is to draw a marker on a map where the address is pointing.
目的是在指向地址的地图上绘制标记。 It works with English characters so far but Finnish (and Swedish) characters 'ä, ö, å' causes trouble.
到目前为止,它可以使用英文字符,但是芬兰(和瑞典)字符“ä,ö,å”会造成麻烦。 I found this: Swedish characters in google geocode request
我发现了这一点: Google地理编码请求中的瑞典语字符
, but it didn't help. ,但没有帮助。
For example this address doesn't have any problems: 例如,此地址没有任何问题:
"Mannerheimintie 10, Helsinki, Finland"
But this one has: 但是这个有:
"Läntinen polku 10, Espoo, Finland"
Here's my code: 这是我的代码:
geocoder = new google.maps.Geocoder();
geocoder.geocode({
'address': address
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
...
... // do something
...
I tried with these parameters also but didn't work: 我也尝试了这些参数,但没有用:
geocoder = new google.maps.Geocoder();
geocoder.geocode({
'address': address,
'region': 'FI' // I tried also with 'language':'fi'
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
...
... // do something
...
The API in use is Google Maps JavaScript API v3. 使用的API是Google Maps JavaScript API v3。 ( https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple )
( https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple )
So how do I tell this API to use Finnish (or Swedish) characters? 那么,如何告诉该API使用芬兰(或瑞典)字符?
当您包含google js文件时,请尝试添加&language=fi
进行本地化。
See the localization section of the documentation: https://developers.google.com/maps/documentation/javascript/basics#Localization 请参阅文档的本地化部分: https : //developers.google.com/maps/documentation/javascript/basics#Localization
You can add the language
attribute to the Google JS files to use a specific language. 您可以将
language
属性添加到Google JS文件以使用特定的语言。
For Finnish, use the following script
tag: 对于芬兰语,请使用以下
script
标记:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?language=fi">
EDIT 编辑
So, it seems that adding the language
attribute just seems to control the language used by Google when rendering the results. 因此,似乎添加
language
属性似乎只是控制了呈现结果时Google使用的语言。 For example, when specifying fi
, the map produced would have everything in Finnish. 例如,当指定
fi
,生成的地图将使用芬兰语。
I used the Geocoding example provided by Google to create this JSBin: http://jsbin.com/ciroluwi/1/edit?html,js,output 我使用Google提供的地址解析示例来创建此JSBin: http ://jsbin.com/ciroluwi/1/edit?html,js,output
Now, admittedly my knowledge of Finnish geography is limited but it seems to me that the address: "Läntinen polku 10, Espoo, Finland", provided by the OP is being located correctly. 现在,我承认对芬兰地理的了解是有限的,但在我看来,由OP提供的地址:“芬兰埃斯波的Läntinenpolku 10”正确定位了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.