netchicken Active Member Licensed User Longtime User Dec 2, 2011 #1 I need to surround the newaddress variable with " " in the following url. weatherurl = "http://maps.googleapis.com/maps/api/geocode/xml?address=" & newaddress & "&sensor=False" I used Chr(34) as a replacement in weatherurl = "http://maps.googleapis.com/maps/api/geocode/xml?address="& Chr(34)& newaddress & Chr(34)&"&sensor=False" Which generated the correct string but then I don't think the weatherurl variable could hold it to put it into the following request.InitializeGet(weatherurl) The java error said it had an illegal character in the query at index 56 which is right where the " is. I tried request.InitializeGet("http://maps.googleapis.com/maps/api/geocode/xml?address="& Chr(34)& newaddress & Chr(34)&"&sensor=False") but it just barfed again. Any ideas? Last edited: Dec 2, 2011
I need to surround the newaddress variable with " " in the following url. weatherurl = "http://maps.googleapis.com/maps/api/geocode/xml?address=" & newaddress & "&sensor=False" I used Chr(34) as a replacement in weatherurl = "http://maps.googleapis.com/maps/api/geocode/xml?address="& Chr(34)& newaddress & Chr(34)&"&sensor=False" Which generated the correct string but then I don't think the weatherurl variable could hold it to put it into the following request.InitializeGet(weatherurl) The java error said it had an illegal character in the query at index 56 which is right where the " is. I tried request.InitializeGet("http://maps.googleapis.com/maps/api/geocode/xml?address="& Chr(34)& newaddress & Chr(34)&"&sensor=False") but it just barfed again. Any ideas?
A admac231 Active Member Licensed User Longtime User Dec 2, 2011 #2 Try QUOTE instead of Chr(34) Out of interest, I see nothing about quotes being required on http://code.google.com/apis/maps/documentation/geocoding/#GeocodingRequests. Also, putting %22 as part of the text would have the same effect e.g request.InitializeGet("http://maps.googleapis.com/maps/api/geocode/xml?address=%22"& newaddress & "&22&sensor=False") Last edited: Dec 2, 2011 Upvote 0
Try QUOTE instead of Chr(34) Out of interest, I see nothing about quotes being required on http://code.google.com/apis/maps/documentation/geocoding/#GeocodingRequests. Also, putting %22 as part of the text would have the same effect e.g request.InitializeGet("http://maps.googleapis.com/maps/api/geocode/xml?address=%22"& newaddress & "&22&sensor=False")
netchicken Active Member Licensed User Longtime User Dec 2, 2011 #3 Thanks for that admac, I'll give it a go Upvote 0
netchicken Active Member Licensed User Longtime User Dec 2, 2011 #4 Nope It needs to have the address surrounded with the " " probably because it doesn't like the blanks. Using %22 or %20 doesn't parse them as " or blank, it just messes up the string. This below works when pasted directly into the browser but it does seem to need the quotes to isolate the address. http://maps.googleapis.com/maps/api/geocode/xml?address="Your Address Here"&sensor=False Google example shows + as a placeholder for the space, but that doesn't work either Even QUOTE doesn't work I still get the IllegalArgumentException Illegal character in query even though the output looks perfect. I think it hates it when it gets to here request.InitializeGet(weatherurl) I tried dicing the url up like this request.InitializeGet(weatherurla "E& newaddress "E& weatherurlb) but still no luck Have any other people solved the problem of " in urls? Last edited: Dec 2, 2011 Upvote 0
Nope It needs to have the address surrounded with the " " probably because it doesn't like the blanks. Using %22 or %20 doesn't parse them as " or blank, it just messes up the string. This below works when pasted directly into the browser but it does seem to need the quotes to isolate the address. http://maps.googleapis.com/maps/api/geocode/xml?address="Your Address Here"&sensor=False Google example shows + as a placeholder for the space, but that doesn't work either Even QUOTE doesn't work I still get the IllegalArgumentException Illegal character in query even though the output looks perfect. I think it hates it when it gets to here request.InitializeGet(weatherurl) I tried dicing the url up like this request.InitializeGet(weatherurla "E& newaddress "E& weatherurlb) but still no luck Have any other people solved the problem of " in urls?
NJDude Expert Licensed User Longtime User Dec 2, 2011 #5 Try this: Code: Sub Globals Dim su As StringUtils '<--- String Utils Library End Sub ... weatherurl = "http://maps.googleapis.com/maps/api/geocode/xml?address=" & newaddress & "&sensor=False" weatherurl = su.EncodeUrl(weatherurl, "UTF8") I haven't tested that myself, but probably it needs to be URL Encoded. Give that a shot. Upvote 0
Try this: Code: Sub Globals Dim su As StringUtils '<--- String Utils Library End Sub ... weatherurl = "http://maps.googleapis.com/maps/api/geocode/xml?address=" & newaddress & "&sensor=False" weatherurl = su.EncodeUrl(weatherurl, "UTF8") I haven't tested that myself, but probably it needs to be URL Encoded. Give that a shot.
netchicken Active Member Licensed User Longtime User Dec 2, 2011 #6 Thanks for that NJDude, but it turned my url into a wild and crazy thang. The // and . all became %3A and %2F type characters The url looks OK with QUOTE & newaddress & QUOTE in it its just not working when put into request.InitializeGet(weatherurl) Last edited: Dec 2, 2011 Upvote 0
Thanks for that NJDude, but it turned my url into a wild and crazy thang. The // and . all became %3A and %2F type characters The url looks OK with QUOTE & newaddress & QUOTE in it its just not working when put into request.InitializeGet(weatherurl)
A admac231 Active Member Licensed User Longtime User Dec 2, 2011 #7 What about changing all occurrences of ' ' with '+' in newaddress. newaddress = newaddress.Replace(" ","+") Upvote 0
What about changing all occurrences of ' ' with '+' in newaddress. newaddress = newaddress.Replace(" ","+")
NJDude Expert Licensed User Longtime User Dec 2, 2011 #8 netchicken said: Thanks for that NJDude, but it turned my url into a wild and crazy thang. The // and . all became %3A and %2F type characters The url looks OK with QUOTE & newaddress & QUOTE in it its just not working when put into request.InitializeGet(weatherurl) Click to expand... Well yes, the URL will look coo-coo but that's what URL encoding is all about, some services (not sure about this weather thing) require URL encoding, I have a question for you, what is the problem you are having? not able to send that string or unable the parse the result? Upvote 0
netchicken said: Thanks for that NJDude, but it turned my url into a wild and crazy thang. The // and . all became %3A and %2F type characters The url looks OK with QUOTE & newaddress & QUOTE in it its just not working when put into request.InitializeGet(weatherurl) Click to expand... Well yes, the URL will look coo-coo but that's what URL encoding is all about, some services (not sure about this weather thing) require URL encoding, I have a question for you, what is the problem you are having? not able to send that string or unable the parse the result?
netchicken Active Member Licensed User Longtime User Dec 2, 2011 #9 Thanks admac231, that works!!!!! For anyone who wants to use it it looks like this..... Code: newaddress = edtaddress.Text newaddress = newaddress.Replace(" ","+") addressurl= "http://maps.googleapis.com/maps/api/geocode/xml?address=" & newaddress & "&sensor=false" request.InitializeGet(addressurl) NJdud the problem was getting past the request.InitializeGet(addressurl) part. Last edited: Dec 2, 2011 Upvote 0
Thanks admac231, that works!!!!! For anyone who wants to use it it looks like this..... Code: newaddress = edtaddress.Text newaddress = newaddress.Replace(" ","+") addressurl= "http://maps.googleapis.com/maps/api/geocode/xml?address=" & newaddress & "&sensor=false" request.InitializeGet(addressurl) NJdud the problem was getting past the request.InitializeGet(addressurl) part.