Edit the OpenLayers.Format.Text to read "real" csv-Files
HTML
Edit the OpenLayers.Format.Text to read "real" csv-Files
(jsfiddle here not for live-demo but just to share the code)
save content of javascript-block as js-file ad save it to your OpenLayers-Folder into subfolder lib/OpenLayers/Format
then insert the file after the OpenLayers.js
<script src="jour_OpenLayers_Folder/OpenLayers.js"></script>
<script src="jour_OpenLayers_Folder/lib/OpenLayers/Format/Text_comma.js"></script>
JavaScript
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the 2-clause BSD license.
* See license.txt in the OpenLayers distribution or repository for the
* full text of the license. */
/**
* @requires OpenLayers/Feature/Vector.js
* @requires OpenLayers/Geometry/Point.js
*/
/**
* Class: OpenLayers.Format.Text
* Read Text format. Create a new instance with the <OpenLayers.Format.Text>
* constructor. This reads text which is formatted like CSV text, using
* tabs as the seperator by default. It provides parsing of data originally
* used in the MapViewerService, described on the wiki. This Format is used
* by the <OpenLayers.Layer.Text> class.
*
* Inherits from:
* - <OpenLayers.Format>
*/
OpenLayers.Format.Text = OpenLayers.Class(OpenLayers.Format, {
/**
* APIProperty: defaultStyle
* defaultStyle allows one to control the default styling of the features.
* It should be a symbolizer hash. By default, this is set to match the
* Layer.Text behavior, which is to use the default OpenLayers Icon.
*/
defaultStyle: null,
/**
* APIProperty: extractStyles
* set to true to extract styles from the TSV files, using information
* from the image or icon, iconSize and iconOffset fields. This will result
* in features with a symbolizer (style) property set, using the
* default symbolizer specified in <defaultStyle>. Set to false if you
* wish to use a styleMap or OpenLayers.Style options to style your
* layer instead.
*/
extractStyles: true,
/**
* Constructor: OpenLayers.Format.Text
* Create a new parser for TSV Text.
*
* Parameters:
* options - {Object} An optional object whose properties will be set on
* this instance.
*/
initialize: function(options) {
options = options || {};
if(options.extractStyles !== false) {
...