I tried to fix it by using the json library from json.org:
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20090211</version>
        </dependency>

I changed GeoCoder.java, GeoCoderException.java, and improved
GeoCoderTest.java which run without complains. Sorry, I never committed
to github or any other open source project. If you think I should do so,
please give me some short instruction what I should do.

Dieter Tremel

The central part of Geocoder is
    private final String output = OUTPUT_JSON;

    public GLatLng decode(String response) throws GeocoderException {
        try {
            JSONObject jsonResponse = new JSONObject(response);
            GeocoderException.GeocoderStatus status =
GeocoderException.GeocoderStatus.valueOf(jsonResponse.getString("status"));
            if (status != GeocoderException.GeocoderStatus.OK) {
                throw new GeocoderException(status);
            }
            JSONArray results = jsonResponse.getJSONArray("results");
            JSONObject location =
results.getJSONObject(0).getJSONObject("geometry").getJSONObject("location");
            return new GLatLng(location.getDouble("lat"),
location.getDouble("lng"));
        } catch (JSONException ex) {
            Logger.getLogger(Geocoder.class.getName()).log(Level.SEVERE,
null, ex);
            throw new
GeocoderException(GeocoderException.GeocoderStatus.PARSER_ERROR);
        }
    }

    public String encode(final String address) {
//        changed since this was Google API V2, see
https://developers.google.com/maps/documentation/geocoding/
//        return "http://maps.google.com/maps/geo?q="; +
urlEncode(address) + "&output=" + output;
        StringBuilder sb = new
StringBuilder("http://maps.googleapis.com/maps/api/geocode/";);
        sb.append(output);
        sb.append("?");
        sb.append("address=").append(urlEncode(address));
        sb.append("&sensor=false");
        return sb.toString();
    }

Am 18.03.2013 15:27, schrieb Dieter Tremel:
> Am 16.03.2013 22:43, schrieb Vishal Popat:
>> I am using GMap3 from here: 
>> https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/gmap3-parent/gmap3.
>>  My Geocoding has recently stopped working and is showing Status 610. Google 
>> searching shows that this is all related to GMap2 being deprecated etc 
>> (There maybe other reasons why I am getting a 610).
>>
>> However, when looking here: 
>> https://github.com/wicketstuff/core/blob/master/jdk-1.6-parent/gmap3-parent/gmap3/src/main/java/org/wicketstuff/gmap/geocoder/Geocoder.java.
>>  The encoding url looks like it is from Gmap v2 (see here: 
>> https://developers.google.com/maps/documentation/geocoding/index), which 
>> would explain the 610.
>>
>> Am I mistaken?
> 
> Hello Vishal,
> 
> I have the same problem and think you are right. Geocoder#encode in
> Version 6.5.0 uses an old URL and parses the return value as CSV,
> whereas https://developers.google.com/maps/documentation/geocoding/ only
> talks about JSON and XML return values. The unit test of Geocoder fails
> with error code 610.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to