QUrl Class's *addQueryItem* method - qt

I want to query the Google map for all the roads leading to a given GPS coordinate.
For that I'll have to place a "query" which can be done by: http://doc.qt.io/qt-4.8/qurl.html#addQueryItem
Now I want to know how to figure out that what should be the key and its corresponding value here?
Should the key be "road"/"roads"? Whats the way to decide that? And I want all the roads not a particular one!
Any hints?

An HTTP URL has the following format:
http://some/address?key=value&more=values
The part behind the '?' is your query. You have to determine how the resulting URL should look like and add key/value pairs accordingly.
It isn't completely clear to me what you want to accomplish. You might want to check out these Google Maps API Links:
http://code.google.com/intl/de/apis/maps/documentation/staticmaps/#Addresses
http://code.google.com/intl/de/apis/maps/index.html

Related

URL with multiple parameters, incorrect syntax error

I am integrating with a system that creates part of a URL and I supply part of the URL.
I supply this:
http://myServer/gis/default.aspx?MAP_NAME=myMap
The system supplies this:
?type=mrolls&rolls='123','456'
(the "rolls" change depending on what the user chooses in the system)
so, my URL ends up looking like this:
http://myServer/gis/default.aspx?MAP_NAME=myMap?type=mrolls&rolls='123','456'
I need to get the rolls but when I try this in VB.Net:
Dim URL_ROLL As String = Request.QueryString("rolls")
I get an incorrect syntax error.
I think it's a combination of the 2nd question mark and the single quotes.
When the system is only passing one roll, it works, I can get the rolls from the URL
which looks like this:
http://myServer/gis/default.aspx?MAP_NAME=myMap?type=roll&roll=123
I asked them to change the format of the system's URL but they can't change it without affecting the rest of their users.
Can anyone give me some ideas on how to get the rolls from the URL with single quotes?
OK, I believe I've fixed my problem.
I used a regular expression to remove anything in the querystring that wasn't a number or a comma.
Thanks again for taking time to make your comments, it made me look at the problem from a different angle.

google maps - wrong (different) routes directions

I try to get the instructions of a route direction from two points, but the route appears different when I give the coordinates through the source code (coorect route), than when the function gets them from the textbox. I want you to know that I am interested in finding the route only by the coordinates and not by the address
Thank you in advance
form source code (correct route) - http://www.touchsmart.gr/stackoverflow_map/route_from_variable.html
from textbox (wrong route) - http://www.touchsmart.gr/stackoverflow_map/route_from_text.html
Those are two different things. The correct route is passing in google.map.LatLng objects, the incorrect route is not. To use geographic coordinates you need to pass in google.map.LatLng objects, otherwise the coordinates get geocoded.
destination LatLng|string Location of destination. This can be specified as either a string to be geocoded or a LatLng. Required.
origin LatLng|string Location of origin. This can be specified as either a string to be geocoded or a LatLng. Required.
See this question for how to convert a comma separated string to a google.maps.LatLng object.

Find segment ID in Google analytics?

I am trying to output the content of a Google Analytics segment using a script called Oochart.
To do this I need the segment ID, how do I find this?
There's no simple way. You either have to try to read it from the URL when you apply the segment, or select the segment in the query explorer (http://ga-dev-tools.appspot.com/explorer/) which will then show the segment ID.
While the best answer is the one from LCarey (to use the Query Explorer: http://ga-dev-tools.appspot.com/explorer/) I found that the answer from Pavel needs update if you want to go that way instead, as the URL structure has changed.
Consider the following URL:
https://analytics.google.com/analytics/web/#report/defaultid/a23080303w45291587p45450834/%3F_.useg%3DuserfSRDEURzSXe_Kspo6mxgXw/
You're looking for the string "_.useg%3Duser", after which the segment ID (fSRDEURzSXe_Kspo6mxgXw) follows. To use this in API I would use gaid::fSRDEURzSXe_Kspo6mxgXw.
The advanced segment feed provides a listing of all the default and user-created advanced segments. You can retrieve the ID of all the segments here in this standalone Explorer. (under the Try it! headline):
https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/segments/list#try-it
You'll need to authenticate the requests using OAuth 2.0.
As LCarey briefly mentioned, you can read it from URL. I will clarify that by example.
Apply the segment and see the URL.
Example:
https://www.google.com/analytics/web/#report/visitors-overview/a27824002w53282758p54121492/%3F_.advseg%3Duser1417962107/
You are looking for advseg parameter. In this case the segment ID is user1417962107. Characters %3D mean encoded equal sign "=".
In API you would use segment=gaid::user1417962107

Documentation for Google maps MarkerImage url string in constructor

The first argument of the google.maps.MarkerImage class constructor is a url string with several GET variables.
This is an example of the url string in use. The color variable is clear, but what do the other variables do?
Yes, what Trott says. Basically the markerimage URL is a relative or absolute url to an image, nothing more or less. So depending on where you get your images from, it might have a querystring on it (e.g. if the marker is to be dynamically generated by a server-side script). So in this case you just happen to be using the Charts API to get a dynamic image for your marker.
The first argument is not necessarily a URL string with several GET parameters. It is simply a URL string. Google Maps API uses that URL to retrieve the image. If there are GET parameters, they are used (or ignored) by the server from which the image is being retrieved.
The example you link to contains a URL using Google's Charts API. The definitions for the parameters are at http://code.google.com/apis/chart/image/docs/chart_params.html.

Using Json.NET to parse result returned by Google Maps API

I am trying to use google map api's web service to make a web request, and get the json string, and then get the latitude and longitude I need for the input address.
Everything is fine. I got the json string I need.
Now I am using Json.net to parse the string.
I don't know why, but I simply cannot convert it into a JArray.
Here is the json string
Can anyone teach me how to write the c# code to get the lat and lng in geometry > location?
Thanks
Here is my codes and the bug screenshot
You have a few options when using JSON.NET to Parse the JSON.
The best option, IMHO, is to use Serialization to pull the object back into a structured type that you can manipulate as you could any other class. For this you can see serialization in the JSON.NET documentation (I can also post more details if that isn't clear enough).
If all you want is to grab the address, as you listed in your question, you can also use the LINQ feature to pull that information back. You could use code similar to the following to pull it off (the key lies in the SelectToken method to pull back the details you need).
Dim json As Newtonsoft.Json.Linq.JObject
json = Newtonsoft.Json.Linq.JObject.Parse(jsonString)
json.SelectToken("results.formatted_address").ToString()
You can also use all the normal power of Linq to traverse the JSON as you'd expect. See the LINQ documentation as well.
[I realize this is an old question, but in the off chance it helps someone else...]
The problem here is that json["results"] is a JArray, but you are not querying it like one. You need to use an array index to get the first (and only, in this case) element, then you can access the objects inside it.
string address = json["results"][0]["formatted_address"].Value<string>();
To get the latitude and longitude you can do:
JToken location = json["results"][0]["geometry"]["location"];
double lat = location["lat"].Value<double>();
double lng = location["lng"].Value<double>();

Resources