maxsokolov / googlekit Goto Github PK
View Code? Open in Web Editor NEWAn Objective-C wrapper around the various Google API's
License: MIT License
An Objective-C wrapper around the various Google API's
License: MIT License
Максим, в некоторых запросах присутствует проперти location - например, здесь:
GKGeocoderQuery *query = [GKGeocoderQuery query];
// required parameters
query.key = @"key";
query.location = CLLocationCoordinate2DMake(0.0f, 0.0f);
Это, конечно, непринципиально, но немного сбивает с толку - дело в том, что есть две сущности с координатами - CLLocation
и CLLocationCoordinate2D
- и обычно стараются делать так, чтобы имя проперти соответствовало типу сущности. Т.е. если я вижу query.location
, то я буду почти уверен, что это CLLocation, и буду сильно удивлен, когда окажется, что это не так. Мелочь, конечно, но если вы измените имя, скажем, на query.coordinate
, многие спасибо скажут. :)
Максим, вот этот запрос не работает:
GKGeocoderQuery *query = [GKGeocoderQuery query];
query.coordinate = _myLocation.coordinate;
query.language = @"en";
[query lookupAddress:^(NSArray *results, NSError *error)
{
if (error)
return;
GKGeocoderPlace *place = [results firstObject];
_myLocationAddress = place.formattedAddress;
}];
Возвращается пустой result
, хотя ошибок нет. В отладчике видно, что происходит обращение к суперклассу (GKQuery
), в котором соответствующий метод-шаблон возвращает nil
.
I was using this lib, worked ok, but suddenly stopped bringing data... for any search term
Вызывающий код:
- (void)buttonSearchPressed:(id)sender
{
[self dismissKeyboard];
NSLog(@"<%@>", _searchBar.text);
GKPlacesQuery *query = [GKPlacesQuery query];
query.key = @"keykeykey";
query.language = @"en";
query.text = _searchBar.text;
[query textSearch:^(NSArray *results, NSString *nextPageToken, NSError *error)
{
if (results)
NSLog(@"Search OK");
}];
}
Ожидаемый URL запроса:
https://maps.googleapis.com/maps/api/place/textsearch/json?query=london&language=en&sensor=false&key=keykeykey
Фактический URL запроса:
https://maps.googleapis.com/maps/api/place/textsearch/json?key=keykeykey&query=(null)&location=0.000000,0.000000&rankby=prominence&radius=1000&language=en
Обратите внимание на (null)
- куда-то потерялся сам текст запроса ("london"). Кроме того, отсутствие параметра, например, location вовсе не равно присутствию этого параметра с нулевыми координатами - нулевые координаты так же, как и любые другие, обозначают место на земной поверхности, поэтому неясно, на каком основании вы добавляете этот и другие параметры с какими-то дефолтными значениями. Эти параметры опциональны в API, зачем вы их добавляете принудительно?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.