How to use own Geocoder Service instead of L.Control.Geocoder.nominatim() - leaflet

I'm running my own Geocoder Service(I installed based on installation guide)
It is Geo.mygovernmentonline.org.
And here is my code.
L.Control.geocoder().addTo(map);
var routeControl = L.Routing.control({
waypoints: [],
serviceUrl: 'https://osrm.mgoconnect.org/route/v1',
geocoder: L.Control.Geocoder.nominatim(),
routeWhileDragging: true,
}).addTo(map);
var geocoder = L.Control.Geocoder.nominatim();
geocoder.geocode(address[i][0], function (results) {
if (results[0] !== undefined) {
resolve(L.latLng(results[0].properties.lat, results[0].properties.lon));
} else {
resolve()
}
})
As I mentioned in Title, now I would like to use my own Geocoder Service instead of geocoder: L.Control.Geocoder.nominatim(), var geocoder = L.Control.Geocoder.nominatim()
Please help me.
Thank you!

Related

how to implement sort method in sails,js when i run in postman it give me error

How to implement sort method in sails js when i run this code
Code :
try{
let sort = req.param('name')
let mysort = {}
mysort.name = sort;
// console.log(mysort)
let find = await dynamic.find().sort(mysort) //used to find All records from Database
console.log(find)
return res.status(200).json({
"success" : true,
"find" : find
})
}
Expecting = sorted database(records)
Any Solution for this?

How to recompute Route in Sygic

my issue is simple I compute a primary route and I added it to Sygic MapView. I defined the startWay point and also the the end point. It works perfectly. But when I try to change to the alternative route when I started the navigation It can't recalculate perfectly the new route. I Used the
func navigation(_ navigation: SYNavigation, didUpdate positionInfo: SYPositionInfo?) {
to detect changes in my position and compute the route every time but I think is not the best choice:
func navigation(_ navigation: SYNavigation, didUpdate positionInfo: SYPositionInfo?) {
if (mapRoute != nil){
mapView.remove(mapRoute)
computeRoute(from: startPointMP, to: endPointMP)
}
}
func computeRoute(from fromCoordinate: SYGeoCoordinate, to toCoordinate:
SYGeoCoordinate) {
let startWaypoint = SYWaypoint(position: fromCoordinate, type: .start, name: "Begin")
let endWaypoint = SYWaypoint(position: toCoordinate, type: .end, name: "End")
let routingOptions = SYRoutingOptions()
routingOptions.transportMode = .unknown// For other options see SYTransportMode
routingOptions.routingType = .economic// For other options see SYRoutingType
routing.computeRoute(startWaypoint, to: endWaypoint, via: nil, with: routingOptions)
}
func routing(_ routing: SYRouting, didComputePrimaryRoute route: SYRoute?) {
SYNavigation.shared().start(with: route)
// You might want to put it also on the map
mapRoute = SYMapRoute(route: route!, type: .primary)
markerEnd = SYMapMarker(coordinate: endPointMP!, image: UIImage(named: "Arrive")!)
mapView.add(mapRoute)
mapView.add(markerEnd)
mapView.add(markerStart)
mapView.cameraMovementMode = .free
}

Swift OAuth2 p2

I've been trying for a while to get oauth2 to work with Untappd api (https://untappd.com/api/docs#authentication) and have been running into dead ends with a few different oauth2 frameworks.
I've been trying P2 OAuth. I seem to be able to kick off the auth process, user signs in, I get a code back and run into trouble sending that code back to untappd for a token. I've been going off of the example from P2 oauth:
class ViewController: UIViewController {
fileprivate var alamofireManager: SessionManager?
var loader: OAuth2DataLoader?
var oauth2 = OAuth2CodeGrantNoTokenType(settings: [
"client_id": "A0******************",
"client_secret": "BA******************",
"authorize_uri": "https://untappd.com/oauth/authenticate",
"token_uri": "https://untappd.com/oauth/authorize",
"redirect_uris": ["****://oauthcallback"],
"response_type": "code",
"secret_in_body": false,
"keychain": true,
] as OAuth2JSON)
#IBOutlet var imageView: UIImageView?
#IBOutlet var signInEmbeddedButton: UIButton?
#IBOutlet var signInSafariButton: UIButton?
#IBOutlet var signInAutoButton: UIButton?
#IBOutlet var forgetButton: UIButton?
#IBAction func signInEmbedded(_ sender: UIButton?) {
if oauth2.isAuthorizing {
oauth2.abortAuthorization()
return
}
sender?.setTitle("Authorizing...", for: UIControlState.normal)
oauth2.authConfig.authorizeEmbedded = true
oauth2.authConfig.authorizeContext = self
oauth2.verbose = true
oauth2.authorize() { authParameters, error in
if let params = authParameters {
print("Authorized! Access token is in `oauth2.accessToken`")
print("Authorized! Additional parameters: \(params)")
}
else {
print("Authorization was cancelled or went wrong: \(error)") // error will not be nil
}
}
}
In the logs I seem to get back the code but the final exchange fails:
[Debug] OAuth2: Exchanging code 2010D2*********** for access token at https://untappd.com/oauth/authorize
redirecting
[Debug] OAuth2: Did exchange code for access [false] and refresh [false] tokens
Authorized! Access token is in oauth2.accessToken
Authorized! Additional parameters: ["meta": {
"error_detail" = "Missing either the client_id, redirect_url, client_secret or code parameter. Please check your request a try again.";
"error_type" = "param_error";
"http_code" = 500;
}, "response": <__NSArray0 0x174005900>(
)
]
There doesn't seem to be much help for OAuth2 and Swift 3, unless I'm looking in the wrong places. Any ideas?
Figured this out. In case anyone else runs into this. Turns out just had to modify the OAuth2CodeGrant class to add in the client_secret that wasn't being passed during the code exchange for token:
open func accessTokenRequest(with code: String, params: OAuth2StringDict? = nil) throws -> OAuth2AuthRequest {
guard let clientId = clientConfig.clientId, !clientId.isEmpty else {
throw OAuth2Error.noClientId
}
guard let redirect = context.redirectURL else {
throw OAuth2Error.noRedirectURL
}
guard let clientSecret = clientConfig.clientSecret else {
throw OAuth2Error.noClientSecret
}
let req = OAuth2AuthRequest(url: (clientConfig.tokenURL ?? clientConfig.authorizeURL), method: .GET)
req.params["code"] = code
req.params["grant_type"] = type(of: self).grantType
req.params["redirect_uri"] = redirect
req.params["client_id"] = clientId
req.params["client_secret"] = clientSecret
return req
}

Creating Dialog issue in private Chat with Quickblox

I am trying to implement private 1 to 1 chat with QuickBlox but following the Quickblox docs only shows for group chat in http://quickblox.com/developers/Chat#Create_dialog . When I try sending just single occupants_ids, it gives following error :
{
"errors": [
"Occupants_ids cannot be less than one."
]
}
I am hitting create Dialog API with following body :
{
"type": 3,
"name": "",
"occupant_id": "13822296"
}
Do I need to update some keys in my request body?
Please check: Create new 1-1(private) chat dialog
Code from documentaton work for me:
let chatDialog: QBChatDialog = QBChatDialog(dialogID: nil, type: QBChatDialogType.Private)
chatDialog.occupantIDs = [user.ID]
QBRequest.createDialog(chatDialog, successBlock: {(response: QBResponse?, createdDialog: QBChatDialog?) in completion?(response: response, createdDialog: chatDialog)
print("sucess + \(response)")
}, errorBlock: {(response: QBResponse!) in
print("response + \(response)")
})
QBChatDialog *chatDialog = [[QBChatDialog alloc] initWithDialogID:null type:QBChatDialogTypePrivate];
chatDialog.occupantIDs = #[#(1530190)];
[QBRequest createDialog:chatDialog successBlock:^(QBResponse *response, QBChatDialog *createdDialog) {
} errorBlock:^(QBResponse *response) {
}];
you can use this and you should provide one occupantIds. If it works please let me know.
let user = QBUUser()
user.id = UInt(arrDoctors[sender.tag].QuickBloxId)!
user.fullName = arrDoctors[sender.tag].title.capitalizeFirst
ServicesManager.instance().chatService.createPrivateChatDialog(withOpponent: user) { (response, dialog) in
let chatvc = CHAT_STORYBOARD.instantiateViewController(withIdentifier: "ChatViewController") as! ChatViewController
chatvc.dialog = dialog
self.navigationController?.pushViewController(chatvc, animated: true)
}

Unable to Update User: UserCannotBeAlteredWithoutSessionError

Greetings from a Parse Neophyte:
Task: Update current user's attributes (in Parse's User table).
Problem: Received the 'UserCannotBeAlteredWithoutSessionError' error.
Here's my code:
func updateParseUser(newUser:User, sender:UIViewController) {
let currentUser = PFUser.currentUser()
if ((currentUser) == nil) {
return
}
if let location = newUser.location {
currentUser["location"] = location
}
if let phone = newUser.phoneNumber {
currentUser["phone"] = phone
}
currentUser["displayName"] = "Turkey"
PFUser.currentUser().save()
}
Result:
Error: Parse::UserCannotBeAlteredWithoutSessionError (Code: 206, Version: 1.5.0)
Do I need to create a session or something?
Remedy?
Update your SDK. I had the exact same issue. When I updated to 1.6.0 the issue resolved itself.