Different locations between maps.google.com and Google Maps API

32 views
Skip to first unread message

Alexander

unread,
Dec 1, 2011, 7:14:52 AM12/1/11
to google-map...@googlegroups.com
Hi all,

I will summarize what the problem is. I have to draw TWO different routes in the same map. This is afaik only possible by using the Google Maps API. But using that gives me less accurate positions. When I draw the route directly in maps.google.com by filling the querystring it will give me the exact positions.

For example:
http://maps.google.com/maps?saddr=51.979362,5.980457&daddr=51.979402,5.975447+to:51.976466,5.975393&via=1&t=m
http://www.stuurhut.nl/google/map.html?origin=51.979362,5.980457&destination=51.976466,5.975393&waypoints=51.979402,5.975447

The map and directions in the second url are made with help of the API.

Can somebody explain this? Or can somebody give a solution?

Thanks in advance!

JKurtock

unread,
Dec 1, 2011, 3:15:41 PM12/1/11
to Google Maps JavaScript API v3
I can't speak specifically to maps.google, but the directions API
tries to put the end point(s) of the route at the street in front of
"your house." So if you provide the LatLng of the center of a large
shopping center as the destination, the route will actually end on the
street "in front of" the shopping center.

In your example, your destination LatLng is in the middle of a vacant
lot. (I'm not sure where your LatLng came from, but you can try
dropping a Marker there to see.) It looks like the directions service
is trying to find the nearest "real" address, which looks to be the
office building labelled "Bunzl Verpakkingen Arnhem BV." And that is
where it ends up.

In maps.google, it looks like it is accepting the parking lot (car
park) at the end of Delta (Street) as an acceptable destination.
(This is not too surprising; the geoCoding API in maps.google is
different from the API because the API looks only for addresses,
whereas maps.google includes a Places function as well, so the results
are often different.)

If you assure your destinations are real places, you will probably get
more consistent results between the API and maps.google.com.

- Jeff

On Dec 1, 4:14 am, Alexander <alexander.kersten.1...@gmail.com> wrote:
> Hi all,
>
> I will summarize what the problem is. I have to draw TWO different routes
> in the same map. This is afaik only possible by using the Google Maps API.
> But using that gives me less accurate positions. When I draw the route
> directly in maps.google.com by filling the querystring it will give me the
> exact positions.
>

> For example:http://maps.google.com/maps?saddr=51.979362,5.980457&daddr=51.979402,...http://www.stuurhut.nl/google/map.html?origin=51.979362,5.980457&dest...

Rossko

unread,
Dec 1, 2011, 3:27:31 PM12/1/11
to Google Maps JavaScript API v3
> Or can somebody give a solution?

You might try parsing your text lat/lon strings and create a LatLon
object, which you can pass to Directions instead of strings.
http://code.google.com/apis/maps/documentation/javascript/services.html#DirectionsRequests
I do not know, but suspect, that would avoid the service trying to
second guess where you meant.

Alexander

unread,
Dec 1, 2011, 10:16:58 PM12/1/11
to google-map...@googlegroups.com
@JKurtock thanks! That explains why I get those strange results when I use the Directions API. At least that is clear now. The thing is that I'm scanning for locations (gps of an Android device) and I want to connect those points and get the directions between them. They don't have to be real addresses as you may understand.

@Rossko that is worth trying! I will try it and will let you know if it worked.
Message has been deleted

Alexander

unread,
Dec 1, 2011, 11:49:58 PM12/1/11
to google-map...@googlegroups.com
Thanks Rossko for the great tip! It works! So for everybody who is curious how to get the desired locations: use a LatLng object instead of a String in a DirectionsRequest! Thanks everybody for your time.
Reply all
Reply to author
Forward
0 new messages