简体   繁体   English

Google地图商店定位器未解析CSV

[英]Google maps store locator is not parsing CSV

I m trying to modify the example of Google store locator which can be found here : https://googlemaps.github.io/js-store-locator/examples/panel.html . 我正在尝试修改Google商店定位器的示例,该示例可在以下位置找到: https : //googlemaps.github.io/js-store-locator/examples/panel.html However whatever I try it seems that it can't parse the CSV. 但是,无论我如何尝试,它似乎都无法解析CSV。 I have read this question here Google Maps Store Locator - modify default example , but my CSV is not modified at all. 我在这里已阅读此问题Google Maps Store Locator-修改默认示例 ,但我的CSV根本没有修改。 I didn't even open it, to edit it. 我什至没有打开它来编辑它。 Just to be clear I didn't modify-change any file of the example, I m just trying to see how it works. 为了清楚起见,我没有修改-更改示例的任何文件,我只是想看看它是如何工作的。 What could be my problem?. 可能是我的问题吗? I have tried so far: 到目前为止,我已经尝试过:

  • Downloading unzipping and running panel.html 下载解压缩并运行panel.html
  • Downloading running without unzipping 下载运行时无需解压缩
  • Downloading to different PC (without excel installation) 下载到其他PC(没有安装excel)
  • Running it from xampp 从xampp运行
  • uploading to a web server 上载到Web服务器

what else can I try? 我还能尝试什么? I really need it working so I can modify it and build a part of my project on it. 我真的需要它工作,因此我可以对其进行修改并在其上构建项目的一部分。 Thanks in advance 提前致谢

This is the code sample (from this blog ) which should give you a guideline. 这是代码示例(来自此Blog ),应该为您提供指导。 Since you haven't posted your code snippet, its hard to tell what exactly is wrong with it. 由于您尚未发布代码段,因此很难说出它到底出了什么问题。

Alternately, you can try using this library . 或者,您可以尝试使用此 Whichever helps. 哪个有帮助。

 <script type="text/javascript"> // ref: http://stackoverflow.com/a/1293163/2343 // This will parse a delimited string into an array of // arrays. The default delimiter is the comma, but this // can be overriden in the second argument. function CSVToArray( strData, strDelimiter ){ // Check to see if the delimiter is defined. If not, // then default to comma. strDelimiter = (strDelimiter || ","); // Create a regular expression to parse the CSV values. var objPattern = new RegExp( ( // Delimiters. "(\\\\" + strDelimiter + "|\\\\r?\\\\n|\\\\r|^)" + // Quoted fields. "(?:\\"([^\\"]*(?:\\"\\"[^\\"]*)*)\\"|" + // Standard fields. "([^\\"\\\\" + strDelimiter + "\\\\r\\\\n]*))" ), "gi" ); // Create an array to hold our data. Give the array // a default empty first row. var arrData = [[]]; // Create an array to hold our individual pattern // matching groups. var arrMatches = null; // Keep looping over the regular expression matches // until we can no longer find a match. while (arrMatches = objPattern.exec( strData )){ // Get the delimiter that was found. var strMatchedDelimiter = arrMatches[ 1 ]; // Check to see if the given delimiter has a length // (is not the start of string) and if it matches // field delimiter. If id does not, then we know // that this delimiter is a row delimiter. if ( strMatchedDelimiter.length && strMatchedDelimiter !== strDelimiter ){ // Since we have reached a new row of data, // add an empty row to our data array. arrData.push( [] ); } var strMatchedValue; // Now that we have our delimiter out of the way, // let's check to see which kind of value we // captured (quoted or unquoted). if (arrMatches[ 2 ]){ // We found a quoted value. When we capture // this value, unescape any double quotes. strMatchedValue = arrMatches[ 2 ].replace( new RegExp( "\\"\\"", "g" ), "\\"" ); } else { // We found a non-quoted value. strMatchedValue = arrMatches[ 3 ]; } // Now that we have our value string, let's add // it to the data array. arrData[ arrData.length - 1 ].push( strMatchedValue ); } // Return the parsed data. return( arrData ); } </script> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM