Force flutter_google_places to only display cities when using GooglePlacesAutocompleteWidget - flutter

I'm using the flutter_google_places widget to search for cities.
I've tried the AutoComplete example given with the widget and it works perfectly. But when I type "Paris" for example, I get many results of places in Paris (Paris, Paris Airport, Paris Expo, etc.).
I only need cities within my App. So for example, when typing "Paris", I would only want "Paris (France), Paris (Texas), Paris (Tennessee), etc.
I haven't found how to apply the "cities" filter.
Here is the equivalent in Javascript :
var input = document.getElementById('searchField');
var options = {
types: ['(cities)']
};
autocomplete = new google.maps.places.Autocomplete(input, options);
Any idea?

If you are using this example: https://github.com/fluttercommunity/flutter_google_places/blob/master/example/lib/main.dart
Should do
CustomSearchScaffold()
: super(
apiKey: kGoogleApiKey,
sessionToken: Uuid().generateV4(),
language: "en",
components: [Component(Component.country, "uk")],
types: ["(cities)"], // or cities
);

Related

sap.viz.ui5.controls.VizFrame.vizSelect() not working as expexted

I use the library sap.viz.ui5.controls.VizFrame to create a pie chart. The chart only contains two values, and I need the first to be highlighted. By Highlighted, I mean selected like if the user would have clicked it, to stand out and show the summary.
Using the vizSelection like this does not work:
oVizFrame.vizSelection(
oVizFrame.getModel().getProperty('/myPath/0'),
{clearSelection : true});
I need to appear the graph showing the relevant value highlighted. /myPath is mapped to the vizFrame.
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions : [{
name : 'Object',
value : "{obj}"}],
measures : [{
name : 'Count',
value : '{Count}'} ],
data : {
path : "/myPath"
}
I found this example:
https://sapui5.hana.ondemand.com/#/sample/sap.viz.sample.SelectionByApi/preview
Confusingly it also does not act as I would expect it after the end-point was highligthed.
sap.ui.getCore().byId('Graphics').vizSelection( selection,{clearSelection : true});
you can use this command and it will work:
selection is an array:
data[Value:1, _context_row_number:1]

Algolia search within scope

I am trying to implement Algolia for a directory. I've created a huge index for listings with data like:
{
"id": 120,
"listing_type": "restaurant",
"location": "In example street, so so area",
"brand":{
"name": "Mc Donald's",
"image":"1130824.jpg",
"description": "Find fastest burgers and fries around. "
},
"neighbourhood":{
"name": "Downtown",
"city":{
"name": "Philadelphia",
"state": "PA"
}
},
"_tags":["burgers","fries","fast food","quick service"],
"has_deals": true,
"images":["file1.jpg","file2.jpg"],
...
}
I want to create separate pages for each city, and would like to restrict searches for that specific city. How can I achieve this?
I can find a parameter that can be added here:
var search = instantsearch({
// Replace with your own values
appId: 'xxxxxx',
apiKey: 'xxxx', // search only API key, no ADMIN key
indexName: 'listings',
urlSync: true,
searchParameters: {
hitsPerPage: 10
}
});
There are two ways to restrict a search, both based on the filters. For that you first need to add some single attribute you can filter on for the city to attributesForFaceting (in the settings, for example with the dashboard). In this case we can use neighbourhood.city.
Then in InstantSearch on your page you can add to searchParameters the value: filters: 'neighbourhood.city:Philadelphia'.
You can also use "secured API keys" to refine on this value before actually launching the page. This will prevent someone from taking that API key and searching themselves. Read more about that in the docs

Exclude Filters Using InstantSearch.js?

We are using Algolia to index content from a variety of sources and for a dozen different products. Right now I have one index and product is a configured facet.
I need to find a way to restrict searches to only those products the user owns.
I'm using the InstantSearch library and I've been reading through the documentation and various online forums for information on how to accomplish this.
Here is the code I'm trying to get working.
var client = algoliasearch("myAppId", "myApiKey")
var index = client.initIndex('myIndex');
var search = instantsearch({
appId: 'myAppId',
apiKey: 'myApiKey',
indexName: 'myIndex',
urlSync: {},
attributesToHighlight: 'full'
});
search.addWidget(
instantsearch.widgets.refinementList({
container: '#products',
attributeName: 'products',
operator: 'or',
limit: 100,
sortBy: ['name:asc'],
templates: {
}
})
);
search.addWidget({
init: function (options) {
options.helper.addFacetRefinement('products', 'Product A');
}
});
search.start();
But when I execute this I get an error stating "Uncaught Error: products is not defined in the facets attribute of the helper configuration".
What step am I missing? Or am I approaching this in the wrong way?
Any guidance appreciated.
~ Greg
I found an answer to my needs. I had to add a searchParameters option to the instantsearch configuration call. And I had to write some code to hide the unwanted products from my refinementlist widget.
First step is to create an array of the products I want to hide.
var productsToExclude = ['product-a','product-b'];
I had to pass this list of items to hide via the "searchParameters" instantsearch configuration option.
var search = instantsearch({
appId: 'myAppId',
apiKey: 'myApiKey',
indexName: 'myIndex',
urlSync: {},
attributesToHighlight: 'full',
searchParameters: { facetsExcludes: { "products": productsToExclude}}
});
And I also had to write a bit of code to hide the items in the refinementList widget.
var onRenderHandler = function () {
for (var p in productsToExclude) {
$("input[type=checkbox][value='" + productsToExclude[p] + "']").parent().hide();
}
};
search.on('render', onRenderHandler);

Here geocoder API: retrieve route number based on coordinates

I noticed that I can retrieve route number based on coordinates using geocoding service. If coordinates are located outside the city, instead of street name geocoder returns route number (which is very useful).
Sometimes however route has multiple numbers - eg. "A4/E65/5". Unfortunately geocoder returns only one number - eg. "5". Is there any chance that geocoder can return full number?
Goeocder might not work here, have you tried getLinkinfo ?
e.g
http://route.st.nlp.nokia.com/routing/6.2/getlinkinfo.xml?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&waypoint=45.79728,16.13712&linkattributes=all
With Geocoding use "locationattributes=addressNames". That will return many name variants including several languages and road numbers, e.g.
street: [
{
value: "A5",
language: "de"
},
{
value: "E451",
language: "de"
}
]

Post to facebook with multiple cities target

I'm trying to post something with target parameters, and i can do that but specifying only one city. Is there any way to pass two or more cities?
I'm trying this way:
parameters.targeting = new {
countries = "some country",
cities = new [] { new { key = "city value" }, new { key = "other city value" } },
locales = "locale code"
};
But no success! How can i do this?
This is very unclear, but I am guessing you are just not formatting your array of cities correctly. See more here: https://developers.facebook.com/docs/reference/ads-api/targeting-specs/
I believe you should be using "name" instead of "key" for the cities, but again I really don't have enough information to go off of.
Specify key, radius & distance_unit. For key, see Targeting Search,
Cities. radius is a distance around cities, from 10 to 50 miles or 17
to 80 kilometers. distance_unit is mile or kilometer. Limit: 250.
Example: 'cities': [{'key':'2430536', 'radius':12,
'distance_unit':'mile'}]
Source: https://developers.facebook.com/docs/marketing-api/buying-api/targeting#location