How to get nearby places from Google SDK using iOS and Swift? - ios

How I can get nearby location from Google SDK in iOS and Swift? I need all nearby places without any type and category?
Client don't want use this url: https://maps.googleapis.com/maps/api/place/search/json?location=lat,long&radius=1000&sensor=true&key=key

You can simply do this with this API call:
https://maps.googleapis.com/maps/api/distancematrix/json?origins=51.226531,4.190688&destinations=51.114476,4.139618|51.148123,4.182590
There are three parameters in this URL,
JSON is used to return the response
origins contain the long and lat of the current location of the user and
destination contains all the addresses form which you want to find the nearest distance. the addresses will be in long and lat format and are separated by "|".
The response will be as follow
{
"destination_addresses" : [
"Dorpstraat 70, 9140 Temse, België",
"Eigenlostraat 38, 9100 Sint-Niklaas, België"
],
"origin_addresses" : [ "Provinciale Baan 37, 9120 Beveren, België" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "16,3 km",
"value" : 16346
},
"duration" : {
"text" : "22 min.",
"value" : 1321
},
"status" : "OK"
},
{
"distance" : {
"text" : "10,5 km",
"value" : 10521
},
"duration" : {
"text" : "17 min.",
"value" : 1003
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
All you have to do is to get the nearest destination on the time basis .
Cheers

Related

Is it possible to create Salesreceipt without product/service value through QBO API?

Is it possible to create Salesreceipt without product/service value through QBO API? I have tried through API but it's not reflecting rate value and storing description value only.
If I remove ItemRef attribute(in request body) then it's reflecting rate and amount values and it's assigning some default and random product/service.
It is possible directly in QBO UI.
Request body where only description value storing:
{
"TxnDate" : "2016-05-27",
"Line" : [ {
"Amount" : 2222.00,
"Description" : "hi chk",
"DetailType" : "ItemReceiptLineDetail",
"ItemReceiptLineDetail" : {
"ItemRef" : { },
"Qty" : 1,
"UnitPrice" : 2222
} }
],
"CustomerRef" : {
"value" : "67"
},
"CustomerMemo" : {
"value" : "Thanks for your business! We appreciate referrals!"
},
"TotalAmt": 2222.00,
"PrivateNote" : "",
"CustomField" : [ {
"DefinitionId" : "1",
"Type" : "StringType",
"StringValue" : ""
} ]
}
Request body where default product/service assigning:
{
"TxnDate" : "2016-05-27",
"Line" : [ {
"Amount" : 2222.00,
"Description" : "hi chk",
"DetailType" : "ItemReceiptLineDetail",
"ItemReceiptLineDetail" : {
"Qty" : 1,
"UnitPrice" : 2222
} }
],
"CustomerRef" : {
"value" : "67"
},
"CustomerMemo" : {
"value" : "Thanks for your business! We appreciate referrals!"
},
"TotalAmt": 2222.00,
"PrivateNote" : "",
"CustomField" : [ {
"DefinitionId" : "1",
"Type" : "StringType",
"StringValue" : ""
} ]
}
No.
QuickBooks Online does not support this.

no implicit conversion of String into Integer (TypeError)

Sorry for novice question, i am a beginner in JSON.
I have the following json:
{
"destination_addresses" : [ "San Francisco, Californie, États-Unis", "Victoria, BC, Canada" ],
"origin_addresses" : [ "Vancouver, BC, Canada", "Seattle, Washington, États-Unis" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "1 707 km",
"value" : 1707145
},
"duration" : {
"text" : "3 jours 19 heures",
"value" : 327471
},
"status" : "OK"
},
]
},
],
"status" : "OK"
}
and i am going to get duration value.
i used this line
duration = json["rows"][0]["elements"]["duration"]["text"]
but i am facing with this erorr
no implicit conversion of String into Integer (TypeError)
Looking at the example JSON, elements is an array:
"elements" : [...
so needs to be indexed numerically e.g.
duration = json["rows"][0]["elements"][0]["duration"]["text"]
currently the string "duration" is being used to index into the elements array leading to the error you're seeing.

Why my PassBook isn't valid or outdate?

I generate one passbook using this gem in rails and it seen that works but when I open the passbook .pkpass file I see this message:
It's in spanish but basically it says that this card isn't valid anymore.
Here is my JSON:
{
"formatVersion" : 1,
"passTypeIdentifier" : "{MY PASS ID HERE}",
"serialNumber" : "E5982H-I2",
"teamIdentifier" : "{MY TEAM ID HERE}",
"webServiceURL" : "https://example.com/passes/",
"authenticationToken" : "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc",
"barcode" : {
"message" : "123456789",
"format" : "PKBarcodeFormatPDF417",
"messageEncoding" : "iso-8859-1"
},
"locations" : [
{
"longitude" : -122.3748889,
"latitude" : 37.6189722
},
{
"longitude" : -122.03118,
"latitude" : 37.33182
}
],
"organizationName" : "CROCANTICKETS SL",
"description" : "Paw Planet Coupon",
"logoText" : "Paw Planet",
"foregroundColor" : "rgb(255, 255, 255)",
"backgroundColor" : "#FF4B33",
"coupon" : {
"primaryFields" : [
{
"key" : "offer",
"label" : "Any premium dog food",
"value" : "20% off"
}
],
"auxiliaryFields" : [
{
"key" : "expires",
"label" : "EXPIRES",
"value" : "2016-04-24T10:00-05:00",
"isRelative" : true,
"dateStyle" : "PKDateStyleShort"
}
]
}
}
Any idea? Thanks!
According to the Expiration Keys in the Passbook Package Format Reference check the expirationDate and voided keys. Since you do not have those in your JSON, it might be added by the gem you are using.

Step-by-Step navigation by using GPS in iOS sdk [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want Step by Step navigation by using GPS with google Maps and how to achieve that one.
Any help really appreciated
Thank you
you need a google API Services and they provide full Route path when you give Startpoint and Destination point and call the api with the following
http://maps.google.com/maps/api/directions/json?sensor=true&origin=23.027439,72.523089&destination=23.029108,72.507570
here my startingpoint is origin=23.027439,72.523089 and destintaion is destination=23.029108,72.507570
so now google will provide following data
{
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 23.0296906,
"lng" : 72.5234184
},
"southwest" : {
"lat" : 23.026354,
"lng" : 72.50715599999999
}
},
"copyrights" : "Map data ©2014 Google",
"legs" : [
{
"distance" : {
"text" : "2.2 km",
"value" : 2249
},
"duration" : {
"text" : "5 mins",
"value" : 325
},
"end_address" : "Sarkhej - Gandhinagar Highway, Satellite, Ahmedabad, Gujarat 380054, India",
"end_location" : {
"lat" : 23.0290924,
"lng" : 72.5076297
},
"start_address" : "38, Indus Park, Satellite, Ahmedabad, Gujarat 380015, India",
"start_location" : {
"lat" : 23.027439,
"lng" : 72.5230894
},
"steps" : [
{
"distance" : {
"text" : "68 m",
"value" : 68
},
"duration" : {
"text" : "1 min",
"value" : 24
},
"end_location" : {
"lat" : 23.0269233,
"lng" : 72.5227287
},
"html_instructions" : "Head \u003cb\u003esouthwest\u003c/b\u003e toward \u003cb\u003eSatellite Rd\u003c/b\u003e",
"polyline" : {
"points" : "oppkCitsyLXPJFh#\\VN"
},
"start_location" : {
"lat" : 23.027439,
"lng" : 72.5230894
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "85 m",
"value" : 85
},
"duration" : {
"text" : "1 min",
"value" : 30
},
"end_location" : {
"lat" : 23.0265039,
"lng" : 72.5234184
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eSatellite Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Hanuman Mandir (on the left)\u003c/div\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "gmpkCarsyLVa#`#u#Pc#FM"
},
"start_location" : {
"lat" : 23.0269233,
"lng" : 72.5227287
},
"travel_mode" : "DRIVING"
},
you have to understand the documentation for using google direction services for that here is the link https://developers.google.com/maps/documentation/javascript/directions.
here is a simple logic you can use after that.
what you have to do is to store this steps dictionaryArray in array and then try to fetch it one by one.
Check didUpdateToLocation method for current Lat Long and if your current location is near by the vlaue of step Dcitionay's endLocation point and if its near by then you can alert the message of html_instructions Value that which direction user has to go next and increase your index for steps array dictionary and same do it for the last index of steps.
if need any help feel free to ask.

Read JSON data returned by google maps

In my app I use the BlackBerry API to get latitude and longitude. I would like to do reverse geocoding using Google maps by creating an http connection. How do I parse the data, and then read a specific element, such as the address?
An example URL:
http://maps.google.com/maps/geo?json&ll=9.6,73.7
Gives response:
{
"name": "9.600000,76.760000",
"Status": {
"code": 200,
"request": "geocode"
},
"Placemark": [ {
"id": "p1",
"address": "Kanjirappalli Elikkulam Rd, Kerala, India",
"AddressDetails": {
"Accuracy" : 6,
"Country" : {
"AdministrativeArea" : {
"AdministrativeAreaName" : "Kerala",
"SubAdministrativeArea" : {
"SubAdministrativeAreaName" : "Kottayam",
"Thoroughfare" : {
"ThoroughfareName" : "Kanjirappalli Elikkulam Rd"
}
}
},
"CountryName" : "India",
"CountryNameCode" : "IN"
}
Use the JSON ME library. See Using JSON in Java ME for examples of how to use it.

Resources