On Thu, Mar 25, 2010 at 11:27 AM, Sheepz <[email protected]> wrote:
> 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?
>
This is not an intended use of the JS API, so I don't recommend this. As
you've found, the JS service produces JS Objects not JSON.
Are you concerned for the load on your servers or ours?
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.
>
The v3 API consistently promotes {lat: ..., lng:...} structures to
google.maps.LatLng objects (and likewise for LatLngBounds). JS developers
find this much more convenient than having to promote these structures for
themselves.
Cheers
Ben
Thanks,
> e.
>
> On Mar 24, 8:11 pm, Ben Appleton <[email protected]> wrote:
> > On Thu, Mar 25, 2010 at 9:49 AM, Sheepz <[email protected]> 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...
> >
> >
> >
> > > My java code is fairly simple for example's sake, it is:
> >
> > > 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...
> >
> > The JS geocoder is only intended for use by JS. Have you considered
> using
> > the web service from your server?
> >
> > > e.
> >
> > > On Mar 24, 6:25 pm, Ben Appleton <[email protected]> wrote:
> > > > To be sure, you mean the JavaScript Geocoder (
> > >http://code.google.com/apis/maps/documentation/v3/services.html#Geoco..
> .)
> > > > not the HTTP Web Service (
> > >http://code.google.com/apis/maps/documentation/geocoding/index.html)
> > > right?
> >
> > > > The JavaScript Geocoder does not return JSON, it returns a JavaScript
> > > > Object. For convenience we provide google.maps.LatLng and
> > > > google.maps.LatLngBounds instances where appropriate, not eg.
> {lat:...,
> > > > lng:...} structs.
> >
> > > > What is your Java code - are you using GWT or are you passing the
> geocode
> > > > result to a Java server?
> >
> > > > - Ben
> >
> > > > On Thu, Mar 25, 2010 at 8:29 AM, Sheepz <[email protected]> wrote:
> > > > > Thanks for the answer but if possible, I'd appreciate some more
> > > > > details, I understand that this is not something you consider as a
> > > > > defect, can you please elaborate on why you say that? is there a
> way
> > > > > to stringify this correctly and I'm just not using it? my
> workaround
> > > > > at the moment is some search and replace method that runs on the
> > > > > object on the server side but it seems like something is being done
> > > > > wrong, either on my end or in the implementation, so please
> elaborate
> > > > > in your response.
> > > > > Tia,
> > > > > Elad.
> >
> > > > > On Mar 24, 5:12 pm, Ben Appleton <[email protected]> wrote:
> > > > >> This is working as intended.
> >
> > > > >> On 25 Mar 2010 08:02, "Sheepz" <[email protected]> wrote:
> >
> > > > >> Hi All, I'm using Json to parse the gecode result and pass it to
> my
> > > > >> java code, where I rebuild it.
> > > > >> This it my JS code for parsing the result to a string:
> > > > >> var myJSONText = JSON.stringify(results[0],
> null);
> > > > >> it returns the following for a query about Germany:
> > > > >> "[
> > > > >> {
> > > > >> "types":["country","political"],
> > > > >> "formatted_address":"Deutschland",
> > > > >> "address_components":
> > > > >> [{"long_name":"Deutschland","short_name":"DE","types":
> > > > >> ["country","political"]}],
> > > > >> "geometry":{
> > > > >> "location":{"b":51.165691,"c":10.451526},
> > > > >> "location_type":"APPROXIMATE",
> >
> > > "viewport":{"c":{"b":47.4430843,"c":54.6103698},"b":{"d":180,"c":
> > > > >> 2.255725,"b":18.647327}},
> > > > >> "bounds":{"c":{"b":47.270127,"c":55.0815},"b":{"d":180,"c":
> > > > >> 5.8663566,"b":15.0418536}}}}
> >
> > > > >> ]"
> >
> > > > >> 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?
> >
> > > > >> --
> > > > >> 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
> >
> > > > [email protected].>> To unsubscribe from this
> > > group, send email to
> > > > >> [email protected]<google-maps-js-api-v3%[email protected]>
> <google-maps-js-api-v3%[email protected]<google-maps-js-api-v3%[email protected]>
> >
> > > <google-maps-js-api-v3%[email protected]<google-maps-js-api-v3%[email protected]>
> <google-maps-js-api-v3%[email protected]<google-maps-js-api-v3%[email protected]>
> >
> >
> > > > <google-maps-js-api-v3%[email protected]<google-maps-js-api-v3%[email protected]>
> <google-maps-js-api-v3%[email protected]<google-maps-js-api-v3%[email protected]>
> >
> > > <google-maps-js-api-v3%[email protected]<google-maps-js-api-v3%[email protected]>
> <google-maps-js-api-v3%[email protected]<google-maps-js-api-v3%[email protected]>
> >
> >
> > > > >> .
> > > > >> For more options, visit this group athttp://
> >
> > > > groups.google.com/group/google-maps-js-api-v3?hl=en.
> >
> > > > > --
> > > > > 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
> >
> > > > [email protected].> To unsubscribe from this
> group,
> > > send email to
> >
> > > > [email protected]<google-maps-js-api-v3%[email protected]>
> <google-maps-js-api-v3%[email protected]<google-maps-js-api-v3%[email protected]>
> >
> > > <google-maps-js-api-v3%[email protected]<google-maps-js-api-v3%[email protected]>
> <google-maps-js-api-v3%[email protected]<google-maps-js-api-v3%[email protected]>
> >
> >
> > > > .> For more options, visit this group at
> >
> > > >http://groups.google.com/group/google-maps-js-api-v3?hl=en.
> >
> > > --
> > > 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
> > > [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<google-maps-js-api-v3%[email protected]>
> <google-maps-js-api-v3%[email protected]<google-maps-js-api-v3%[email protected]>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> --
> 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
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-maps-js-api-v3%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.