Note the location, viewport and bounds.
These are not proper json objects and are therefore parsed in a way
that cannot be used to reconstruct the object on the java side.
The objects in question are the LatLng and the LatLngBounds objects.
Is this a bug that's going to be fixed soon?
Am i missing something in the way i parse it?
This is working as intended.
--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
On Mar 24, 5:12 pm, Ben Appleton <apple...@google.com> wrote:
> This is working as intended.
>
> google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2Bunsu...@googlegroups.com>
JAVA SIDE:
~~~~~~~~~
private void handleCallback(String result, String status,
AjaxRequestTarget target) {
JSONDeserializer<GeocodeResult> deser =new
JSONDeserializer<GeocodeResult>();
deser.use( null, GeocodeResult.class );
String fixedResult = fixResult(result);
System.out.println("fixedResult=["+fixedResult+"]");
GeocodeResult resultObject =
deser.deserialize( fixedResult );
System.out.println("at handleCallBack with result: ["+result
+"] and status:["+status+"] and result object: ["+resultObject+"]");
}
private String fixResult(String result) {
return result.replaceAll("(location.*?)\"b\"(.*?)\"c\"",
"$1\"lat\"$2\"lon\"");
}
HTML SIDE:
~~~~~~~~~
function handleResponse(results, status){
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
var myJSONText = JSON.stringify(results[0], null);
wicketCallBack(myJSONText,status);
} else {
alert("Geocode was not successful for the
following reason: " + status);
}
}
NOTES:
~~~~~~
I'm using ajax for moving the data around, my web framework is wicket
(not GWT), running on tomcat with liferay portal, flexJson on the
server side, and json2.js (from jquery) on the client side.
If there's any other data that you need, I'll be happy to provide it!
I understand that you do not provide the json structure for the latlng
and the latlngbounds object, which is kind of the reason for the post
- why not? I'm sure I'm not the only one that's doing this - moving
data from javascript to java and back is kinda the point of json so
the logic of doing it half way eludes me...
e.
On Mar 24, 6:25 pm, Ben Appleton <apple...@google.com> wrote:
> To be sure, you mean the JavaScript Geocoder (http://code.google.com/apis/maps/documentation/v3/services.html#Geoco...)
> <google-maps-js-api-v3%2Bunsu...@googlegroups.com<google-maps-js-api-v3%252Buns...@googlegroups.com>
I'm using the Javascript Geocoder.
However, according to the documentation found at:
http://code.google.com/apis/maps/documentation/v3/services.html#GeocodingResponses
: "The GeocoderResults object literal is a JSON object ..."
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
On Mar 24, 8:11 pm, Ben Appleton <apple...@google.com> wrote:
> On Thu, Mar 25, 2010 at 9:49 AM, Sheepz <eladk...@gmail.com> wrote:
> > I'm using the Javascript Geocoder.
> > However, according to the documentation found at:
>
> >http://code.google.com/apis/maps/documentation/v3/services.html#Geoco...
> > : "The GeocoderResults object literal is a JSON object ..."
>
> I've asked our docs guy to fix that. The authoritative reference is here:http://code.google.com/apis/maps/documentation/v3/reference.html#Geoc...
> > > <google-maps-js-api-v3%2Bunsu...@googlegroups.com<google-maps-js-api-v3%252Buns...@googlegroups.com>
> > <google-maps-js-api-v3%252Buns...@googlegroups.com<google-maps-js-api-v3%25252Bun...@googlegroups.com>
Thanks for the reply.
I did consider using the server to perform the call, however, to
reduce load on the servers, I decided to do a client side call, are
you suggesting that we should not do it this way?
Also, I think that I must reiterate my point since I really do love
using google products, and since the maps API is still in 'labs', I
urge you to reconsider using the a jsonised version of the LatLng and
BoundsLatLng objects since it will be consistent with the rest of the
v3 api and will make life much simpler for people like me in the
future.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
Because almost every use for this requires an actual JS object. Why
force the majority of developers to create a LatLng object?
I believe your root issue is that the LatLng object serializes to
something you can't use. Instead of using JSON.stringify, why not
create your own function to walk through the returned data and create
a proper JSON string. The function wouldn't even be that complex.
Chad Killingsworth
I appreciate the responses and their promptness, keep up the good
work!
e.
On Mar 25, 2:24 pm, Chad Killingsworth
Sorry for taking a bit to respond. There's actually no contradiction
between what I wrote in my blog post and what Ben wrote. The JS
geocoder is meant primarily for use in the JS API. So we wrote it in
such a way that it would be most efficient for that purpose, and give
you the best performance. To create an additional JSON output would
bloat the code a bit.
That said, there's nothing wrong with taking some of the properties
you get and sending them to the server for processing. It's not the
primary focus of the JS geocoding API, but it is a use case we
support.
Mano