Google maps api geocoder - restrict to multiple countries - api

Im using google geocoder and I want to restrict result to some countries (for example I don't want to search in USA).
Using:
componentRestrictions: {
country: 'de'
}
Works fine, but I would like to add more countries, tried passing array:
componentRestrictions: {
country: ['de','at','ch']
}
But it gives an error
Is there anyway to add more than one country to restrictions?
Thanks

Related

How to get user country without gps

In react native i am trying to get user country without using the users gps, just like Wechat registration which automatically gets the users country in the picker(select) field.
it can be done by two ways
get the IP address of user but it works only with internet connection
the best way is to get the local country of the device itself with the use of
react-native-device-info
const deviceCountry = DeviceInfo.getDeviceCountry(); // "US", "IN"
ref: react-native-device-info#getdevicecountry
getDeviceCountry() is removed from react-native-device-info.
Use react-native-localize:
import * as RNLocalize from "react-native-localize";
RNLocalize.getCountry(); // -> 'UA'
If you want to get a full country name like "United States" then you can add following json file to your project: https://gist.github.com/ssskip/5a94bfcd2835bf1dea52
And then import and get full country name by code:
const countries = require('./countries.json')
// Or in ES6:
// import countries from './countries.json'
countries[RNLocalize.getCountry()] // -> 'United States'

Use BigCommerce API to get a list of prices and name only

I have an bigcommerce headless ecom site. I keep data synced to my own database so I dont have to rely on bc api calls for every user.
Problem now is that certain data changes often. Like prices. — How can i use the BigCommerce api to get a list of only prices/name/id the list would loook like the below.
[
{
name: xxx,
id: xxx,
calculated_price: xxx,
},
{
name: xxx,
id: xxx,
calculated_price: xxx,
},
]
You can use the ?include_fields parameter to control the fields in the response when using the V3 Catalog API.
For example:
GET /v3/catalog/products?include_fields=calculated_price,name
IDs will always be returned.
From there you could apply other filters to control which items are returned in the collection.
If you also need variant prices, try including the variants with ?include=variants

How to find Trello ListId's or CardId's with Trello.NET

I'm trying to find all cards in a specific list using Trello.NET
In the examples given it's clear to to find all list names in a Board, and all Cards in a Board. However if I want to find all Cards in a specific List, as far as I can see I need ListID (can't filter by List Name) by using trello.Lists.WithId()
Knowing the List name, how can I determine what it's ListId is so I can subsequently filter for all Cards in it?
And if I would subsequently like to edit an existing Card, how can I determine the CardId.
Use LINQ and filter in-memory:
// More than one list can have the exact same name, this finds the first:
var list = trello.Lists
.ForBoard(board)
.FirstOrDefault(list => list.Name == "name of the list");
if (list != null)
{
var cards = trello.Cards.ForList(list);
// ...
}
You could use a similar technique to find a card if you know it's name: use trello.Cards.ForBoard or trello.Cards.ForList first, and then filter by name afterwards.
For cards there is another option though: trello.Cards.Search. For example:
var cards = trello.Cards.Search("name of the card");
The search will be performed on the server in this case.

how to get the latitude or longitude in HTML 5

few month ago i write something to get the latitude or longitude from google API. latter i get the database from drupal for latitude or longitude to most of city in worlds.
but the problem is that the same city name can be found two or more times in a area. like Firozabad in India and bangladesh both. Agra in UP and agar in Rajasthan.
means the confusion in name by user if they found two city by same name they are confused.
i hear that HTML 5 support latitude or longitude of the visiter but i need latitude or longitude where they are born or city they want to use to fill a form.
how i can get the latitude or longtiude from API like google and some other.
the process is that:
user put the location in textbox for getting their latitude or longitude.
for right thing i want to show them all location [if same thing found more then one].
they can choose the right location and after click they can get the lati and langitude.
how i can do this using any API.
If I understood you correctly then here's a Javascript function that returns a list of actual locations based on the address (full or partial) that user has entered:
getLocationsByAddress = function(address, onComplete) {
var geocoder = null;
var locations = [];
var location = null;
geocoder = new GClientGeocoder();
geocoder.getLocations(address, function(response) {
if (!response || response.Status.code != 200) {
if (typeof (onComplete) != 'undefined') {
onComplete([]);
}
} else {
for (var i = 0; i < response.Placemark.length; i++) {
location = response.Placemark[i];
locations[locations.length] = {
address: location.address,
x: location.Point.coordinates[1],
y: location.Point.coordinates[0],
zoom: 14
}
}
if (typeof (onComplete) != 'undefined') {
onComplete(locations);
}
}
});
}
The code uses API version 2 but I think it should be fairly easy to make it work with V3 (please see this API reference for details).
UPDATE
As #Maxym stated the V2 API is considered as deprecated and therefore shouldn't be used any further.
Take a look at this jQuery plugin. It claims to work with both V2 and V3 so you may want to examine the source code in order to find out how they do an it with V3.
I am not sure that it is about HTML 5. You just need to create sort of hints, where user can select which exactly city she means (the way Google does on maps.google.com - you enter "Odessa" and see list of cities with such name). Google has geocoder API but probably it should be used with Google Map (just read license).
So the process is easy: user enters city, you send it to geocoder to get list of cities with such a name and their coordinates. THen you show that list, user selects one and you have its coordinates.
There is documentation how to use Geocoding API v3 in JavaScript, as well as examples. This one show how to get coordinates from address, take into account that they process results[0] only, but you need to iterate over results to get all cities.

How do I convert from a location (address) String to a YGeoPoint in Yahoo Maps API?

I have a list of addresses from a Database for which I'd like to put markers on a Yahoo Map. The addMarker() method on YMap takes a YGeoPoint, which requires a latitude and longitude. However, Yahoo Maps must know how to convert from addresses because drawZoomAndCenter(LocationType,ZoomLevel) can take an address. I could convert by using drawZoomAndCenter() then getCenterLatLon() but is there a better way, which doesn't require a draw?
You can ask the map object to do the geoCoding, and catch the callback:
<script type="text/javascript">
var map = new YMap(document.getElementById('map'));
map.drawZoomAndCenter("Algeria", 17);
map.geoCodeAddress("Cambridge, UK");
YEvent.Capture(map, EventsList.onEndGeoCode, function(geoCode) {
if (geoCode.success)
map.addOverlay(new YMarker(geoCode.GeoPoint));
});
</script>
One thing to beware of -- in this example the drawAndZoom call will itself make a geoCoding request, so you'll get the callback from that too. You might want to filter that out, or set the map's centre based on a GeoPoint.
If you're working with U.S. addresses, you can use geocoder.us, which has APIs.
Also, Google Maps Hacks has a hack, "Hack 62. Find the Latitude and Longitude of a Street Address", for that.