Help with Google Maps and Polylines
March 8, 2007 1:41 PM   RSS feed for this thread Subscribe

I do web work with a local government. We are wanting to put a lot of GIS related data on the web, and I'd like to use Google Maps before we lobby for a larger solution like ArcServer. I'm specifically having a problem with drawing polygons/polylines and the ordering of points.

Here's how I usually get the Lat/Lng:

- Ask guy in GIS department. He fires up Arc Software, and exports.

- I take .DBF file that Arc generated, and manipulate it to generate the javascript needed to be used by Google Maps API.

- I draw a polyline, but it looks very jumbled, like this

I think it is related to the order that the points are being driven. Does anyone have ideas about getting the data returned to me so the points get drawn correctly?

note: the URL in this post is supposed to be a bike path in the city. I'm using GPolyline. If anyone wants to see code, I'm more than happy to share...
posted by bofe to computers & internet (9 comments total) 3 users marked this as a favorite
Here are the steps for translating lat/long to encoded points for the polyline. Creating the actual algorithm is beyond my ability.

This might be a heckuva lot easier.

But personally, if the path is relatively direct, I'd sort the dbf by the lat/long fields.
posted by desjardins at 2:51 PM on March 8, 2007


A friend of mine successfully used lat/lon data to display US Census data on Google Maps. You might try contacting her and see what approach she took. You can see her project implemented at http://maps.webfoot.com/
posted by sanitycheck at 2:55 PM on March 8, 2007 [1 favorite]



A friend of mine successfully used lat/lon data to display US Census data on Google Maps. You might try contacting her and see what approach she took. You can see her project implemented at http://maps.webfoot.com/

Hey, Ducky was my TA for a user interface design class @ UBC.
posted by juv3nal at 3:14 PM on March 8, 2007


I haven't done exactly what you're trying to do, and have done almost nothing with Google Maps, only Google Earth. But on the off chance it helps you, here's an ArcGIS extension to convert a shapefile to KML. Hmm, skimming Google's page, it doesn't look like having something in KML will help much for the JavaScript. Sorry.
posted by salvia at 6:09 PM on March 8, 2007 [1 favorite]


That doesn't look like a point ordering problem to me so much as a problem with the "take .DBF file that Arc generated, and manipulate it" step. I've done some GMaps API GIS stuff, if you send me the code you're using to convert your dbf, and a sample dbf file, I'd be happy to take a look at it. My address is my mefi name at elsewhere.org.
posted by hades at 12:23 AM on March 9, 2007


@desjardins,

"But personally, if the path is relatively direct, I'd sort the dbf by the lat/long fields."

Sort it by lat/long how? ascending? descending? by lat first? by long first?

Thanks!
posted by bofe at 8:52 AM on March 9, 2007


I think you're right after all, and this is a point ordering problem. The problem is that the guy in the GIS department is giving you a file that's just a collection of points. It's not a collection of _ordered_ points, which is what you'd need in order to reconstruct these into lines that make sense. There are a few fields in the DBF that I thought might be clues as to what order to put the points in (LINK_I, LENGT and MILE), but when I tried ordering them that way, the lines didn't look any better.

I think what you're going to need to do is ask your GIS guy to export in some other format--one that preserves lines as lines, rather than just dumping them as assorted points. I think there are tools that let you display ESRI shapefiles on a Google map. This page might be a good place to start.

You could also just plot the points as individual dots on the map, instead of trying to connect them as lines.
posted by hades at 10:51 AM on March 9, 2007


Any suggestion on what format that would be -- or if there is an additional field that needs to come with the DBF? The GIS guys here are great, I just have to be able to articlulate the type of problem I'm having to them.

Thanks so much for your help.
posted by bofe at 11:06 AM on March 9, 2007


You need some way to identify what the next point on a route is. Points could be given identifiers and then each line in the DBF could have a field for the current identifier and a field for a pointer to the next identifier on the route. If a path has multiple segments, then you'd need to treat each segment as its own path with a start point, an end point, and an ordered list of points in between. A shapefile ought to have the information you need, provided that the paths exist as 2-d vectors, not just a collection of points. If you make sure your GIS folks know that you need line segments, not points, they ought to be able to suggest something.
posted by hades at 1:27 PM on March 9, 2007


« Older How do I become less lazy?...   |   I'm moving out of my San Franc... Newer »
This thread is closed to new comments.