+ if ( !$res->is_success || $json_error ) {
+ warn "Error using google GeoCoding API";
+ warn Dumper( $json_res || $res->decoded_content );
+ return;
+ }
+
+ if (
+ ref $json_res
+ && ref $json_res->{results}
+ && ref $json_res->{results}->[0]
+ && ref $json_res->{results}->[0]->{geometry}
+ && ref $json_res->{results}->[0]->{geometry}->{location}
+ ) {
+ my $location = $json_res->{results}->[0]->{geometry}->{location};
+ if ( $location->{lat} && $location->{lng} ) {
+ $self->set( latitude => $location->{lat} );
+ $self->set( longitude => $location->{lng} );
+ $self->set( coord_auto => 'Y' );
+ }
+ } else {
+ # If google changes the API response structure, warnings abound
+ warn "No location match found using google GeoCoding API for $address";
+ warn Dumper( $json_res || $res->decoded_content );
+ }