Esa's Google Maps API experiments

CSV filesMap Kitchen [Part 1]GPolygon data from a text file

File formats like XML/KML and JSON are great but a comma separated text file CSV is the simpliest format to create and maintain. You can do that by any text editor or spreadsheet. Databases export CSV too.

You can 'draw' a CSV file by this polyline editor.

Markers and their infowindow have been done by csv-formatted text files before. Why not polylines too.

Functions and methods:

  • The text file is downloaded by GDownloadUrl()
  • parseCsv() splits the text file into data cells and returns an array of GLatLng() objects.
  • Corrupted lines are skipped.
  • makeDrawing() draws the polyline/polygon.
  • parseCsv() will be included in the mapKitchen JavaScript library.
Application in mind?
  • Copy/paste the code from this page as a template.
  • Make a CSV text file with lines: lng,lat \n
  • Yes. Longitude first. That is a GPS 'standard' but there is an option for inversing them.
  • Read the source. It is commented with some instructions.
  • .txt extension or 'real' .csv, no matter.
More experiments  |  Blog