Google Groups Home
Help | Sign in
Snap To Street From XML
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 28 - Collapse all   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mini0n  
View profile
(1 user)  More options Oct 6 2008, 11:39 am
From: Mini0n <jfvolive...@gmail.com>
Date: Mon, 6 Oct 2008 08:39:33 -0700 (PDT)
Local: Mon, Oct 6 2008 11:39 am
Subject: Snap To Street From XML
Hi there!

I'm trying to get some coordinates from a database, insert them into a
XML file and them show them on the map, snapped to the nearest road.

The thing is I am having problems because the asynchronous thing.

What's the best option to avoid/step over it?

I read setTimeout is not the best choice, but even that I'm unable to
make work... =(

I'm doing this locally, so there's no link to a website. =/

Here's my code:

// This is the array of locations. It's "hand made" now, but it' will
be dynamic, loaded from the XML file
var points = [];
points[0] = new GLatLng(39.761616,-8.804662);
points[1] = new GLatLng(39.734353,-8.773785);
points[2] = new GLatLng(39.740363,-8.810359);

i=0;
while(i < points.length)
{
alert(i);
if (firstpoint)
{
dirn.loadFromWaypoints([points[i],points[i]],{getPolyline:true});
firstpoint = false;

}

else
{
dirn.loadFromWaypoints([points[i-1],points[i]],{getPolyline:true});

}

GEvent.addListener(dirn,"load", function()
{
// snap to last vertex in the polyline
var n = dirn.getPolyline().getVertexCount();
var p = dirn.getPolyline().getVertex(n-1);
var marker=new GMarker(p);
map.addOverlay(marker);
gmarkers.push(marker);
if (!firstpoint)
{
map.addOverlay(dirn.getPolyline());
gpolys.push(dirn.getPolyline());

}
});
i++;
}

If my only alternative was to use setTimeout, where would I put it?
Which function would it call?

Thanks guys!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
geocodezip@gmail.com  
View profile
 More options Oct 6 2008, 11:42 am
From: "geocode...@gmail.com" <geocode...@gmail.com>
Date: Mon, 6 Oct 2008 08:42:59 -0700 (PDT)
Local: Mon, Oct 6 2008 11:42 am
Subject: Re: Snap To Street From XML
On Oct 6, 8:39 am, Mini0n <jfvolive...@gmail.com> wrote:

> Hi there!

> I'm trying to get some coordinates from a database, insert them into a
> XML file and them show them on the map, snapped to the nearest road.

> The thing is I am having problems because the asynchronous thing.

> What's the best option to avoid/step over it?

> I read setTimeout is not the best choice, but even that I'm unable to
> make work... =(

Use the callback function to process the returned data.

> I'm doing this locally, so there's no link to a website. =/

Good luck...

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mini0n  
View profile
 More options Oct 6 2008, 12:25 pm
From: Mini0n <jfvolive...@gmail.com>
Date: Mon, 6 Oct 2008 09:25:26 -0700 (PDT)
Local: Mon, Oct 6 2008 12:25 pm
Subject: Re: Snap To Street From XML
On Oct 6, 4:42 pm, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:

> > I'm doing this locally, so there's no link to a website. =/

> Good luck...

Thanks! Somehow you reminded me of awardspace... ^_^

There: http://gmapstest.awardspace.com/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
geocodezip@gmail.com  
View profile
 More options Oct 6 2008, 1:10 pm
From: "geocode...@gmail.com" <geocode...@gmail.com>
Date: Mon, 6 Oct 2008 10:10:30 -0700 (PDT)
Local: Mon, Oct 6 2008 1:10 pm
Subject: Re: Snap To Street From XML
On Oct 6, 9:25 am, Mini0n <jfvolive...@gmail.com> wrote:

> On Oct 6, 4:42 pm, "geocode...@gmail.com" <geocode...@gmail.com>
> wrote:

> > > I'm doing this locally, so there's no link to a website. =/

> > Good luck...

> Thanks! Somehow you reminded me of awardspace... ^_^

> There:http://gmapstest.awardspace.com/

Looks like those points are already "snapped" to the nearest road.
If you write the code inside the GDirections "load" event handler, you
shouldn't have any problem with the asynchronous nature of the call.
You can do them all in a single call to loadFromWaypoints, just pass
the array of points in and then to retrieve them use
GDirections.getGeocode(i).Point.coordinates (returns array lng, lat,
alt).
  -- Larry

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mini0n  
View profile
 More options Oct 6 2008, 1:39 pm
From: Mini0n <jfvolive...@gmail.com>
Date: Mon, 6 Oct 2008 10:39:37 -0700 (PDT)
Local: Mon, Oct 6 2008 1:39 pm
Subject: Re: Snap To Street From XML
Humm..

Those points are already snapped because I picked them from some
streets.
My purpose is to receive GPS coordinates from a moving car and to snap
them. Those come a little off-street and need snapping.

Now, about your second part, I'm not following.

You're saying I should do something like:

var dirn = new GDirections(map);
dirn.load(function(){
  //function here

});

Once inside, instead

dirn.loadFromWaypoints([points[i],points[i]],{getPolyline:true});

is just

dirn.loadFromWaypoints(points,{getPolyline:true});

?
It might not be near that, but I'm really confused now...

If you could please give me some guiding code, I would appreciate a
LOT! =)

Thanks!

On Oct 6, 6:10 pm, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
geocodezip@gmail.com  
View profile
 More options Oct 6 2008, 1:46 pm
From: "geocode...@gmail.com" <geocode...@gmail.com>
Date: Mon, 6 Oct 2008 10:46:13 -0700 (PDT)
Local: Mon, Oct 6 2008 1:46 pm
Subject: Re: Snap To Street From XML
On Oct 6, 10:39 am, Mini0n <jfvolive...@gmail.com> wrote:

http://www.geocodezip.com/Mini0n_gmapstest_awardspaceE.asp


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mini0n  
View profile
 More options Oct 6 2008, 1:58 pm
From: Mini0n <jfvolive...@gmail.com>
Date: Mon, 6 Oct 2008 10:58:03 -0700 (PDT)
Local: Mon, Oct 6 2008 1:58 pm
Subject: Re: Snap To Street From XML
OMG!
You rule!

Thanks man! It was exactly what I was trying to do! The distance isn't
working, but I'll try to work that out, after I gather the points from
the XML.
I hope I won't have problems with that!

Many many thanks! =)

On Oct 6, 6:46 pm, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mini0n  
View profile
 More options Oct 7 2008, 12:51 pm
From: Mini0n <jfvolive...@gmail.com>
Date: Tue, 7 Oct 2008 09:51:00 -0700 (PDT)
Subject: Re: Snap To Street From XML
Hi there, again! xD

I've realized something now... I want to see more than one route.
Imagine I want to know the path of 2 cars.
As you made in your example, the paths get mixed. Is there anyway to
stop the polyline when one path ends and then, one the other path
starts the polyline draws another line?

Thanks!

On Oct 6, 6:58 pm, Mini0n <jfvolive...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
geocodezip@gmail.com  
View profile
 More options Oct 7 2008, 1:10 pm
From: "geocode...@gmail.com" <geocode...@gmail.com>
Date: Tue, 7 Oct 2008 10:10:31 -0700 (PDT)
Local: Tues, Oct 7 2008 1:10 pm
Subject: Re: Snap To Street From XML
On Oct 7, 9:51 am, Mini0n <jfvolive...@gmail.com> wrote:

> Hi there, again! xD

> I've realized something now... I want to see more than one route.
> Imagine I want to know the path of 2 cars.
> As you made in your example, the paths get mixed. Is there anyway to
> stop the polyline when one path ends and then, one the other path
> starts the polyline draws another line?

Yes.  Do a separate call to GDirections (with a separate array of
points) would be one...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mini0n  
View profile
 More options Oct 9 2008, 1:44 pm
From: Mini0n <jfvolive...@gmail.com>
Date: Thu, 9 Oct 2008 10:44:08 -0700 (PDT)
Local: Thurs, Oct 9 2008 1:44 pm
Subject: Re: Snap To Street From XML
Hello again!

I'm trying to get those damn polylines, but got some issues...

I have successfully gather the info from the .xml, but the polylines
won't appear.

Locally it began giving the "a is undefined" error.

I've uploaded the code to http://gmapstest.awardspace.com/ but it
might have some differences, as locally I have other things. I believe
I've made the correct changes, making both sites equal, except one is
dynamic (local) and the other is static (gmapstest).

Can you see something wrong?

Thanks, once again!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
geocodezip@gmail.com  
View profile
 More options Oct 11 2008, 11:22 am
From: "geocode...@gmail.com" <geocode...@gmail.com>
Date: Sat, 11 Oct 2008 08:22:28 -0700 (PDT)
Local: Sat, Oct 11 2008 11:22 am
Subject: Re: Snap To Street From XML
On Oct 9, 10:44 am, Mini0n <jfvolive...@gmail.com> wrote:

It looks like you don't understand the asynchronous nature of
GXmlHttp.

You send a request for 1234.xml then before it has completed, you
reuse the request object to send a request for 5678.xml.  You have to
wait for it to be finished before  you reuse it.

See Mike Williams' explanation in his tutorial:
Part 2 Asynchronous I/O
http://econym.org.uk/gmap/async.htm

  -- Larry


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mini0n  
View profile