Related
I am trying to make a basic interactive chart where the user can select a country and observe a single measurement based on the height of the bar. However, prior to selecting a country, the chart shows all the bars stacked on top of each other. once a country is selected i achieve the view that i want.
{"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"url": "https://raw.githubusercontent.com/ConorQuah/ConorQuah.github.io/main/Happiness%26liberties_s%26e.csv"
},
"title": {
"text": "Happiness and Liberty",
"subtitle":"view the happiness of different countries. Notice how the colour of the bar changes!",
"subtitleFontStyle":"italic",
"subtitleFontSize":10,
"anchor": "start"
},
"height": 300,
"width": 300,
"transform": [{"filter": {"selection": "Region"}}],
"selection": {
"Region": {
"type": "single",
"fields": ["Country"],
"bind": {
"input": "select",
"options": [
"null",
"Finland",
"Sweden",
"New Zealand",
"United Kingdom",
"Serbia",
"Zimbabwe",
"Afghanistan"
],
"name": "Select a country"
}
}
},
"mark": {"type": "bar", "width":50},
"encoding": {
"color": {
"field": "Civil liberties",
"title": "Civil liberties",
"scale":{"scheme":"redyellowgreen", "domain":[0,60]},
"type": "quantitative"
},
"y": {
"field": "Happiness",
"scale": {"domain": [0,10]},
"type": "quantitative",
"title": "Happiness"
}
}
}
Here you go:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"url": "https://raw.githubusercontent.com/ConorQuah/ConorQuah.github.io/main/Happiness%26liberties_s%26e.csv"
},
"title": {
"text": "Happiness and Liberty",
"subtitle": "view the happiness of different countries. Notice how the colour of the bar changes!",
"subtitleFontStyle": "italic",
"subtitleFontSize": 10,
"anchor": "start"
},
"params": [
{
"name": "p",
"select": {"type": "point", "fields": ["Country"]},
"bind": { "name": "Country",
"input": "select",
"options": [
"Pick a Country",
"Finland",
"Sweden",
"New Zealand",
"United Kingdom",
"Serbia",
"Zimbabwe",
"Afghanistan"
]
}
}
],
"height": 300,
"width": 300,
"transform": [{"filter": "datum.Country ==p_Country"}],
"mark": {"type": "bar", "width": 50},
"encoding": {
"color": {
"field": "Civil liberties",
"title": "Civil liberties",
"scale": {"scheme": "redyellowgreen", "domain": [0, 60]},
"type": "quantitative"
},
"y": {
"field": "Happiness",
"scale": {"domain": [0, 10]},
"type": "quantitative",
"title": "Happiness"
}
}
}
I was planning to migrate from the json API to the rest API, however, the results are not matching, the reverse geocode of the rest API is returning the wrong result. has anyone faced that issue before? Find sample below:
https://revgeocode.search.hereapi.com/v1/revgeocode?at=-32.05786%2C115.93382&lang=en-US&apiKey={KEY}
enter code here {
"items": [
{
"title": "Reece Australia",
"id": "here:pds:place:036qd63w-93b4e78634c7482aa36a7140fde9701b",
"resultType": "place",
"address": {
"label": "Reece Australia, Thornlie WA 6108, Australia",
"countryCode": "AUS",
"countryName": "Australia",
"state": "Western Australia",
"city": "Perth",
"district": "Thornlie",
"postalCode": "6108"
},
"position": {
"lat": -32.05779,
"lng": 115.93393
},
"access": [
{
"lat": -32.05779,
"lng": 115.93393
}
],
"distance": 13,
"categories": [
{
"id": "700-7400-0366",
"primary": true
}
]
}
]
}
https://reverse.geocoder.ls.hereapi.com/6.2/reversegeocode.json?apiKey={APIKEY}&mode=retrieveAddresses&prox=-32.05786,115.93382&maxresults=1
enter code here {
"Response": {
"MetaInfo": {
"Timestamp": "2020-06-25T05:17:32.232+0000",
"NextPageInformation": "2"
},
"View": [
{
"_type": "SearchResultsViewType",
"ViewId": 0,
"Result": [
{
"Relevance": 1.0,
"Distance": 2.1,
"MatchLevel": "street",
"MatchQuality": {
"Country": 1.0,
"State": 1.0,
"City": 1.0,
"District": 1.0,
"Street": [
1.0
],
"PostalCode": 1.0
},
"Location": {
"LocationId": "NT_K800C2SShmW5hJiQktPlsB_l_133454375_L",
"LocationType": "point",
"DisplayPosition": {
"Latitude": -32.0578752,
"Longitude": 115.9338325
},
"MapView": {
"TopLeft": {
"Latitude": -32.05782,
"Longitude": 115.9337
},
"BottomRight": {
"Latitude": -32.05798,
"Longitude": 115.9339
}
},
"Address": {
"Label": "Bannister Rd, Canning Vale WA 6155, Australia",
"Country": "AUS",
"State": "WA",
"City": "Perth",
"District": "Canning Vale",
"Street": "Bannister Rd",
"PostalCode": "6155",
"AdditionalData": [
{
"value": "Australia",
"key": "CountryName"
},
{
"value": "Western Australia",
"key": "StateName"
}
]
},
"MapReference": {
"ReferenceId": "133454375",
"Spot": 0.66,
"SideOfStreet": "neither",
"CountryId": "1469256839",
"StateId": "1469256834",
"CityId": "1469263736",
"DistrictId": "1469282231"
}
}
}
]
}
]
}
}
Result given by Rest API is correct as you are getting accurate result at that coordinate.
while in JSON API you are passing proximities with retrieveAddresses which always search for the closest street address or addresses in the given proximities.
for more details you can visit the documentations for both API.
https://developer.here.com/documentation/geocoding-search-api/api-reference-swagger.html
https://developer.here.com/documentation/geocoder/dev_guide/topics/resource-reverse-geocode.html
Using the here maps autocomplete.geocoder.api v6.2 and passing &language=en parameter, a search returns results with the "label" instead of English language with French language.
This is GET endpoint I'm calling with all the other parameters i use
https://autocomplete.geocoder.api.here.com/6.2/suggest.json
?query=c
&mapview=51.756414,-0.652059,51.309901,0.331888
&app_code=MY_APP_CODE
&app_id=MY_APP_ID
maxresults=15
&country=GBR
&prox=51.508530,-0.076132,30000
&language=en
The result of the above GET endpoint call is this json
{
"suggestions": [
{
"label": "United Kingdom, Comté d'Oxford",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_HTKAfbquVEou80WZXdrniC",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Comté d'Oxford"
},
"distance": 86196,
"matchLevel": "county"
},
{
"label": "United Kingdom, Comté de Hertford",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_szH9Ci92RVY5reHH1VSa6A",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Comté de Hertford"
},
"distance": 26970,
"matchLevel": "county"
},
{
"label": "United Kingdom, Comté de Hampshire",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_IBS0mvpblzLbehAjAMG7.C",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Comté de Hampshire"
},
"distance": 114129,
"matchLevel": "county"
},
{
"label": "United Kingdom, Comté de Berk",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_n-TkgE8S4qt9kGGUkawVGB",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Comté de Berk"
},
"distance": 61719,
"matchLevel": "county"
},
{
"label": "United Kingdom, Comté de Buckingham",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_vX7N0mZ1b4HC5V1DXwy3iA",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Comté de Buckingham"
},
"distance": 75626,
"matchLevel": "county"
},
{
"label": "United Kingdom, CR0 1, Croydon",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_gbk1f7HBWIP8q34qF94w6A",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Surrey",
"city": "Croydon",
"postalCode": "CR0 1"
},
"distance": 15228,
"matchLevel": "city"
},
{
"label": "United Kingdom, London, City of London",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_OIY4l1Ys6bIUnZCJo8RQ7B",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "London",
"city": "London",
"district": "City of London",
"postalCode": "EC1A 4"
},
"distance": 1986,
"matchLevel": "district"
},
{
"label": "United Kingdom, CR0 1, Croydon, Croydon",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_A-KWPtq3xkU9R1OFqELWpA",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Surrey",
"city": "Croydon",
"district": "Croydon",
"postalCode": "CR0 1"
},
"distance": 15228,
"matchLevel": "district"
},
{
"label": "United Kingdom, Comté de Bedford",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_ajXmsYY9XFqUFqvj1ba7wA",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Comté de Bedford"
},
"distance": 47643,
"matchLevel": "county"
},
{
"label": "United Kingdom, Comté de Warwick",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_9PDEEpbiURmpFWb9vPQpeD",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Comté de Warwick"
},
"distance": 147331,
"matchLevel": "county"
},
{
"label": "United Kingdom, CT1 2, Canterbury",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_VD8YPCI.JUqDjxD8sP84AC",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Kent",
"city": "Canterbury",
"postalCode": "CT1 2"
},
"distance": 83989,
"matchLevel": "city"
},
{
"label": "United Kingdom, Comté de Northampton",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_zORnAshlbaC1KPrAO3l7xB",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Comté de Northampton"
},
"distance": 98330,
"matchLevel": "county"
},
{
"label": "United Kingdom, CT1 2, Canterbury, Canterbury",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_jqhKXfcVudUg4b2WGi6teB",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Kent",
"city": "Canterbury",
"district": "Canterbury",
"postalCode": "CT1 2"
},
"distance": 83989,
"matchLevel": "district"
},
{
"label": "United Kingdom, Comté d'Oxford, OX3 0, Oxford, Cheney Student Village",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_Q2z9awYLuQ7mVhvrPipzjC",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Comté d'Oxford",
"city": "Oxford",
"district": "Oxford",
"street": "Cheney Student Village",
"postalCode": "OX3 0"
},
"distance": 84092,
"matchLevel": "street"
},
{
"label": "United Kingdom, Comté d'Oxford, OX1 3, Oxford, Catte Street",
"language": "en",
"countryCode": "GBR",
"locationId": "NT_bQFSMkK5C8pdIWfOI.zTZB",
"address": {
"country": "United Kingdom",
"state": "England",
"county": "Comté d'Oxford",
"city": "Oxford",
"district": "Oxford",
"street": "Catte Street",
"postalCode": "OX1 3"
},
"distance": 85769,
"matchLevel": "street"
}
]
}
Notice that the "label":"United Kingdom, Comté d'Oxford" is in French language instead of the one expected that is English since I'm using the language:en parameter
Regarding documentation on scroll please to language parameter : The preferred language of address elements in the result.
The language parameter must be provided as 2-letter ISO language code. The plural form of the parameter (languages) is not supported and ignored. Only one language can be provided. The language setting changes the language of result elements where available in the map data. The language setting has no impact on matching or ranking and it does not express any regional preference.
The default response language is the language that is most relevant to the query.
Also, the language parameter has no impact on which results are returned because is a preferred(not required), in other words to say the "query" parameter has higher priority(has more impact on matching) unlike the "language" parameter.
I have a Chart in AmCharts, I want to begin the scroll on the top of the graph not on the bottom.
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "light",
"rotate":true,
"maxSelectedSeries": 4,
"mouseWheelScrollEnabled": true,
"marginRight": 70,
"dataProvider": [{
"country": "USA",
"visits": 3025,
"color": "#FF0F00"
}, {
"country": "China",
"visits": 1882,
"color": "#FF6600"
}, {
"country": "Japan",
"visits": 1809,
"color": "#FF9E01"
}, {
"country": "Germany",
"visits": 1322,
"color": "#FCD202"
}, {
"country": "UK",
"visits": 1122,
"color": "#F8FF01"
}, {
"country": "France",
"visits": 1114,
"color": "#B0DE09"
}, {
"country": "India",
"visits": 984,
"color": "#04D215"
}, {
"country": "Spain",
"visits": 711,
"color": "#0D8ECF"
}, {
"country": "Netherlands",
"visits": 665,
"color": "#0D52D1"
}, {
"country": "Russia",
"visits": 580,
"color": "#2A0CD0"
}, {
"country": "South Korea",
"visits": 443,
"color": "#8A0CCF"
}, {
"country": "Canada",
"visits": 441,
"color": "#CD0D74"
}],
"valueAxes": [{
"axisAlpha": 0,
"position": "left",
"title": "Visitors from country"
}],
"startDuration": 1,
"graphs": [{
"balloonText": "<b>[[category]]: [[value]]</b>",
"fillColorsField": "color",
"fillAlphas": 0.9,
"lineAlpha": 0.2,
"type": "column",
"valueField": "visits"
}],
"chartCursor": {
"categoryBalloonEnabled": false,
"cursorAlpha": 0,
"zoomable": false
},
"categoryField": "country",
"categoryAxis": {
"gridPosition": "start",
"labelRotation": 45
},
"chartScrollbar": {
//"graph": "Not set",
"backgroundColor":"#2f373e",
"graphType": "smoothedLine",
"resizeEnabled": false,
"scrollbarHeight": 15,
"scrollDuration": 0,
"updateOnReleaseOnly": true
}
});
jsfiddle
As you can see in the jsfiddle the scrollbar begin on the bottom of the graph and I have to scroll to the top of the graph to see the first result.
It seems that the chart zooms to the end because the maxSelectedSeries property is set - the chart zooms to the last ~x series upon initilzation. You can work around this by adding an init listener that sets the zoom to the desired location upon initilation by calling zoomToIndexes:
var chart = AmCharts.makeChart("chartdiv", {
// ...
"listeners": [{
"event": "init",
"method": function(e) {
e.chart.zoomToIndexes(0, 4);
}
}]
});
Updated fiddle
For a project im doing, I need to get the road names on a route.
So when i go from Amsterdam to Eindhoven, i pass for example the following roads, A4, A5, A27
My question is, how can i get these roads from the google maps api by giving my departure and destination?
All help is very appreciated.
Thanks in advance
Where are you using the Google Maps API you get a JSON format return.
like this;
{
"status": "OK",
"results": [ {
"types": street_address,
"formatted_address": "275-291 Bedford Ave, Brooklyn, NY 11211, USA",
"address_components": [ {
"long_name": "275-291",
"short_name": "275-291",
"types": street_number
}, {
"long_name": "Bedford Ave",
"short_name": "Bedford Ave",
"types": route
}, {
"long_name": "New York",
"short_name": "New York",
"types": [ "locality", "political" ]
}, {
"long_name": "Brooklyn",
"short_name": "Brooklyn",
"types": [ "administrative_area_level_3", "political" ]
}, {
"long_name": "Kings",
"short_name": "Kings",
"types": [ "administrative_area_level_2", "political" ]
}, {
"long_name": "New York",
"short_name": "NY",
"types": [ "administrative_area_level_1", "political" ]
}, {
"long_name": "United States",
"short_name": "US",
"types": [ "country", "political" ]
}, {
"long_name": "11211",
"short_name": "11211",
"types": postal_code
} ],
"geometry": {
"location": {
"lat": 40.7142298,
"lng": -73.9614669
},
"location_type": "RANGE_INTERPOLATED",
"viewport": {
"southwest": {
"lat": 40.7110822,
"lng": -73.9646145
},
"northeast": {
"lat": 40.7173774,
"lng": -73.9583193
}
}
}
},
Pick the long_name, and short_name from address.