Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have many markers in a kml file. All the markers are on the roads.

I wonder if there is a way to process the data and connect the markers by following the road? Of course, the markers should not be randomly connected with each other. The point is to mark the parts of the roads that have markers on them.

I could of course just manually create the lines myself. But there are so many markers, and the data is expanded almost daily.

share|improve this question
what is the roads datasource? what format? – Mapperz Jun 13 '11 at 20:30
I am not sure what you mean. It's a regular Google Map (v3) with mapTypeId google.maps.MapTypeId.ROADMAP and an kml overlay. – reggie Jun 14 '11 at 10:50
Imho, this approach ("matching points to roads in google maps data") won't work. What exactly do you need as a final product? – underdark Jun 14 '11 at 12:22
Do you mean like this example? (the car is animated to the driving directions of the route) – Mapperz Jun 14 '11 at 13:43
@underdark: The result would be polylines along the roads, highlighting the roads that have a high density of markers on them. Like a "heat map" for roads. @Mapperz: No. But the example is very nice, too. :) – reggie Jun 14 '11 at 18:46

AFAIK Google Maps API won't give you access to its underlying vector data. You can use OpenStreetMap instead (which does provide its vector data, and this is often not understood by people). Unless you have vector data, there is no reliable way to match your markers with roads.

You could match each of your markers to the nearest road (using a certain distance tolerance). Then you can simply highlight the roads that have a certain density of markers.

share|improve this answer

In ArcGIS ET Wizzard can import .kml (also arcgis itself can). Latter you could use ET Wizard point->polyline tool (if your data are in order) to create polyline. Not sure how to do it in free soft. Otherwise, since its .xml format and features are marked by tags ie. (simplified) <point><coordinates>x,y</coordinates> and <linestring><coordinates>x,y x,y x,y etc.</coordinates>, maybe you could just edit it in MS Excel to extract points coordinates and stick it in to <linestring> tag. Just a thought.

share|improve this answer
Does this cover "connect the markers by following the road"? – underdark Jun 14 '11 at 10:30
The markers in the kml are random and not in order. I guess sorting them by proximity would be helpful. But I would also need some algorithm to cluster the points together first. Because I am not looking to connect all the dots. I just want to mark those roads that have a high density of markers along them. – reggie Jun 14 '11 at 10:49
Sorry, misunderstood. – Tomek Jun 14 '11 at 10:58

If you are willing to do it with Google Maps the API includes a DirectionsService which can be queried to retrieve a route and can also be used to actually render it with a DirectionsRenderer. The documentation has some pretty good examples.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.