I am working on a project where I need to enter two different
addresses and then using these addresses to get distance between them.
So, I started with getting LatLng objects from address
information( strings) using google maps service. Following
instructions provided in samples at official Google Maps API site, I
did write the following code:

private void getTripDistance(String from, String to){
                final Double distance=0D;

                final String fromAddress=from.trim();
                final String toAddress=to.trim();

                geocoder.getLatLng(fromAddress, new LatLngCallback(){

                        @Override
                        public void onFailure() {
                                // TODO Auto-generated method stub
                                lblDistanceValue.setText("Failed - N/A - From 
Point not found");
                        }

                        @Override
                        public void onSuccess(LatLng point) {
                                // TODO Auto-generated method stub

                                if (fromPoint==null){
                                        lblDistanceValue.setText("N/A - From 
Point not found");
                                        return;
                                }

                                fromPoint=point;

                                geocoder.getLatLng(toAddress, new 
LatLngCallback(){

                                        @Override
                                        public void onFailure() {
                                                // TODO Auto-generated method 
stub
                                        }

                                        @Override
                                        public void onSuccess(LatLng point) {

                                                if (toPoint==null){
                                                        
lblDistanceValue.setText("N/A - To Point not found");
                                                        return;
                                                }

                                                toPoint=point;
                                                Double 
distance=(Double)fromPoint
                                                        .distanceFrom( toPoint, 
6378137);
                                        }
                                });
                        }
                });
        }

where geocoder is:

private Geocoder geocoder=new Geocoder(); - member of a class

My problem is that every time when I run the code it gives me NULL for
fromPoint, so it can't find anything for the given address.

I heard that the problem maybe in using Google services and I need to
get Key (by signing up) but just because I deploy my application
locally just using Eclipse I don't think the problem is in obtaining
the key.

Can you please suggest me any idea how to solve this problem? Do I
need to use other geocoder?
Or maybe I completely misunderstood the way I need to use geocoder?

Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to