Need to get names of places in English in Google Place Autocomplete - google-places-autocomplete

We are using Google Places Autocomplete to fetch address of any location that the user enters. Now, if the user enters Phuket, then the address returned is in Thai language and not English.
I have tried setting language as English
I have tried these options
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&language=en">
</script>
I have also tried
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&language=en&region=GB">
</script>
Similarly for en-AU,en-GP and also language=en&region=AU.
But I still get the name in Thai language instead of English.
I want to see the names in English instead of Thai

I've tried to replicate the issue, using the sample code here, and I was able to get the formatted address of "Phuket, Thailand" which is in English:
See results below:
address_components: [
{
long_name: "Phuket",
short_name: "จ.ภูเก็ต",
types: [
"administrative_area_level_1",
"political"
]
},
{
long_name: "Thailand",
short_name: "TH",
types: [
"country",
"political"
]
}
],
formatted_address: "Phuket, Thailand",
place_id: "ChIJT1JixOIxUDARIbo9BoWayuk",
You can get either the long_name in address_components or the formatted_address which are in English.
Hope this helps!

Related

Google Schema.org Math solvers structured data for multiple fields

Trying to setup schema markup for a simple math solver action with two fields. Let's say addition.
1+1=2
Here is Google's doc and example:
{
"#context": "https://schema.org",
"#type": ["MathSolver", "LearningResource"],
"name": "An awesome math solver",
"url": "https://www.mathdomain.com/",
"usageInfo": "https://www.mathdomain.com/privacy",
"inLanguage": "en",
"potentialAction": [{
"#type": "SolveMathAction",
"target": "https://mathdomain.com/solve?q={math_expression_string}",
"mathExpression-input": "required name=math_expression_string",
"eduQuestionType": ["Polynomial Equation","Derivative"]
}],
"learningResourceType": "Math solver"
}
How do we add multiple variables for two numbers?
return {
'#context': 'https://schema.org',
'#type': ['MathSolver', 'LearningResource'],
...
potentialAction: [
{
'#type': 'SolveMathAction',
target: `domain.com/?num1={num1}&num2={num2}`,
'mathExpression-input': 'required name=num1 name=num2',
eduQuestionType: ['addition', 'sum']
},
],
learningResourceType: 'Math solver'
};
Schema.org says about mathExpression (note: mathExpression-input doesnt seem to exist) but does fall under Thing > Intangible EntryPoint
A mathematical expression (e.g. 'x^2-3x=0') that may be solved for > a specific variable, simplified, or transformed. This can take many > formats, e.g. LaTeX, Ascii-Math, or math as you would write with a > keyboard.
But can this be setup for URL params to accept multiple fields within the mathExpression-input instead of a single math expression?

How can I request pinpoint accurate geocoding data using HERE Api

I am looking to use HEREs geocoding service to locate the Lat and Lon of a place based on a UK postcode. At the moment my request will return a rough location even though I have provided a full postcode.
The old "geocode" API that I used previously, would return relevant results however this has been put into maintenance and replaced with the "geocode and search" API. This new API seems like it just looks through a list of stored points of interest within HERE’s database and returns the closest it can to what you have searched for, rather than trying to find the exact location entered.
How can I get more accurate results using the below request? Bare in mind that I will only have access to the postcode.
https://geocode.search.hereapi.com/v1/geocode?q={postCode}&apiKey={key}
At the moment I receive a response similar to the below using postcode PE1 1QL. It should be pointing to a car park, however if you enter the lat and lon returned from the API into a map E.g Google Maps, it gives you a more general location, rather than an accurate one.
{
"title": "PE1 1, Peterborough, England",
"id": "here:cm:namedplace:22221149",
"resultType": "locality",
"localityType": "postalCode",
"address": {
"label": "PE1 1, Peterborough, England",
"countryCode": "GBR",
"countryName": "England",
"county": "Cambridgeshire",
"city": "Peterborough",
"postalCode": "PE1 1"
},
"position": {
"lat": 52.57362,
"lng": -0.24219
},
"mapView": {
"west": -0.23515,
"south": 52.56739,
"east": -0.25194,
"north": 52.57984
},
"scoring": {
"queryScore": 0.67,
"fieldScore": {
"postalCode": 0.95
}
}
},
I would expect the Lat and Lng to be much closer to the postcode entered than the above example.
Regarding on this release notes https://developer.here.com/documentation/geocoding-search-api/release_notes/topics/known-issues.html
you can read "High precision postal codes are not yet supported":
Known Issues
The following table lists issues known to be present in the current release.
Search for intersections is not yet supported
Search by telephone numbers is not yet supported
Political views are not yet supported. All views are “International”
Places detail views are not yet supported
High precision postal codes are not yet supported
The Geocoder API 6.2 will be supported at least until end of 2020 (maybe more) and "Maintenance" in documentation means: no new features.

What should the "author" field for a LinkedIn UGC post be for Showcase/Brand pages?

I am trying to specify an author for a UGC post to a showcase page. I am expecting that the author of the showcase post is the showcase page itself, which is what happens when I manually create a post, but this doesn't seem to work with the API.
Let's say I have a showcase urn:li:organizationBrand:123456. If I specify the showcase as the author ("author": "urn:li:organizationBrand:123456) I get an error about an invalid "author" field. But if I wrap the brand URN ID with "organization" instead of "organizationBrand" ("author": "urn:li:organization:123456") it works but I have not found this interchangeability documented anywhere.
This same workaround works for retrieving post stats (/organizationalEntityShareStatistics).
Can anyone explain what the right approach is supposed to be?
Are organization brand URNs meant to effectively be an alias of organization URNs?
You can use the organizationalEntityAcls API to find your URN. organization URNs are not necessarily interchangeable with organizationBrand URNs.
For example:
GET https://api.linkedin.com/v2/organizationalEntityAcls?q=roleAssignee
"paging": {
"count": 10,
"start": 0
},
"elements": [
{
"state": "APPROVED",
"role": "ADMINISTRATOR",
"roleAssignee": "urn:li:person:R8302pZx",
"organizationalTarget": "urn:li:organization:1000"
}
]
}
source: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/organizations/organization-access-control#find-access-control-information

Google Places API language=en returns results in other languages

I'm sending the request like this:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?&key=ENTER_YOUR_KEY_HERE&name=&types=restaurant&location=35.79067650569248,107.49634109437466&radius=521711.0&language=en
The query is in China.
and i'm getting results like this:
results: [
{
geometry: {
location: {
lat: 35.737293,
lng: 107.646029
}
},
icon: "https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
id: "759bdf36fa8d5182c6cecb8839d21f5db691ab04",
name: "海底捞火锅西峰店",
place_id: "ChIJwQHr9-k9ZjYRkNpSDzYpfTo",
reference: "CnRrAAAAkM6HlYVwL2mO2sefdojOY7cqX9lQtA_OWt2pFzyGW7p6lj-1oSqFnX3q7_iJtDBGIcoRhqMxriUEXCD4Y8QaBZXhX_7IiqgO_2xHYHN9nWEKOYuPWmuj1V5nTy-D_w-im2OcZVoblKayGDuo2xJTiBIQ2DySEk1zgG1UDKHFnzBxTRoUqsR3fT9UOHrRwOj-hQZZygqxiWo",
scope: "GOOGLE",
types: [
"restaurant",
"food",
"point_of_interest",
"establishment"
],
vicinity: "Xifeng, Qingyang"
},
the name is in Chinese. is there something i can do?
MrUpsidown in the comments is correct: there's no English name for this place in Google's database, so returning the Chinese name Google does have is the best the Places API can do here.

Fetch Latitude Longitude by passing postcodes to maps.google.com using Javascript

I have Postcode in my large database, which contains values like SL5 9JH, LU1 3TQ etc.
Now when I am pasting above postcode to maps.google.com it's pointing to a perfect location..
My requirement is like I want to pass post codes to maps.google.com and it should return a related latitude and longitude of that pointed location, that I want to store in my database.
So, most probably there should be some javascript for that... If anybody have another idea regarding that please provide it..
Thanks in advance...
A quick note for those finding this SO answer. The answer by Daniel Vassallo uses the Google Geocoding API V2 which has now been deprecated. The new v3 API uses a request format like this:
http://maps.googleapis.com/maps/api/geocode/output?parameters
An example for a postcode lookup, returning the data in JSON format is:
http://maps.googleapis.com/maps/api/geocode/json?address=SL59JH,+UK&sensor=false
This returns a JSON array that includes the lat and long in results->geometry->location->lat and results->geometry->location->lng
Example response:
{
"results" : [
{
"address_components" : [
{
"long_name" : "SL5 9JH",
"short_name" : "SL5 9JH",
"types" : [ "postal_code" ]
},
{
"long_name" : "Windsor and Maidenhead",
"short_name" : "Windsor and Maidenhead",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "United Kingdom",
"short_name" : "GB",
"types" : [ "country", "political" ]
},
{
"long_name" : "Ascot",
"short_name" : "Ascot",
"types" : [ "postal_town" ]
}
],
"formatted_address" : "Ascot, Windsor and Maidenhead SL5 9JH, UK",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 51.39655490000001,
"lng" : -0.66024660
},
"southwest" : {
"lat" : 51.39457330,
"lng" : -0.6624574999999999
}
},
"location" : {
"lat" : 51.39539040,
"lng" : -0.66096740
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 51.39691308029150,
"lng" : -0.6600030697084980
},
"southwest" : {
"lat" : 51.39421511970851,
"lng" : -0.6627010302915021
}
}
},
"types" : [ "postal_code" ]
}
],
"status" : "OK"
}
The API spec is available here: https://developers.google.com/maps/documentation/geocoding/
The technical term for the process you describe is called reverse geocoding. Google offers the The Google Geocoding Web Service New working Google Geocoding Link, where you can do reverse geocoding on the server side, instead of in JavaScript on the client-side.
For example, if you try the following URLs in your browser, you would get back the latitude and longitude of the postcode passed in the q parameter, in CSV format:
http://maps.google.com/maps/geo?q=SL59JH,+UK&output=csv&sensor=false
http://maps.google.com/maps/geo?q=LU13TQ,+UK&output=csv&sensor=false
This is how you would be able to reverse geocode your postcodes in php, for example:
$url = 'http://maps.google.com/maps/geo?q=SL59JH,+UK&output=csv&sensor=false';
$data = #file_get_contents($url);
$result = explode(",", $data);
echo $result[0]; // status code
echo $result[1]; // accuracy
echo $result[2]; // latitude
echo $result[3]; // longitude
Note that as Pekka suggested in another answer, the Google Maps API Terms of Use seem to prohibit the storage of the results, unless the store acts as a cache for data that will used in Google Maps. You may want to get in touch with Google and enquire on the Google Maps API Premier to have more flexible terms of use for your geocoding requirements.
The Ordnance Survey have released the postcode locations on a Creative Commons licence (CC-BY v3, IIRC). It would be a lot less hassle (and a lot clearer legally) to use that instead.
There's even a version with WGS84 (a.k.a. GPS) coordinates mirrored by mySociety
The Google Geocoding API does that, although if I remember correctly, their terms of service forbid local storage of the geocoding results.
I know this is an old question, but just chipping in here with how I managed to achieve the same thing (in PHP, but should be fairly simple):
I had a database of thousands of differently formatted postcodes. I cleaned each and every one of them up, uniformly, with this function and batch updates:
function clean_postcode($postcode)
{
$out = preg_replace("/[^a-zA-Z0-9]/", '',strtoupper($postcode));
if(strlen($out)>3)
{
$out = substr($out, 0, (strlen($out) -3)).' '.substr($out, -3);
}
return $out;
}
Now that all postcodes are formatted uniformly, I downloaded and imported the Ordnance Survey's Code-Point data set (free) - https://www.ordnancesurvey.co.uk/opendatadownload/products.html
I imported all their CSVs into my database in a separate codepoint table. From each CSV I imported the postcode, and the Eastings and Northings values.
I ran the clean_postcode() function again in batch on all the Ordnance Survey data in my DB. About 50% of the postcodes have spaces in, and 50% don't - after this they were uniformly set.
I ran the following PHP script on each and every postcode in the codepoint table and saved the Latitude and Longitude values returned into this table: http://bramp.net/blog/os-easting-northing-to-lat-long
All done! You can now match up and pull a Lat/Lon value based on well-formatted postcodes.
Further reading: http://www.deepbluesky.com/blog/-/converting-os-coodinates-into-longitude-latitude_7/
Check out ALgolia places here. Super fast, Open source and MIT

Resources