简体   繁体   English

将数据加载到Google Map API

[英]Load Data to Google Map API

我需要从台式机上的文本文件中读取lat和LNG及其他参数,以读取大学项目中的Google Map Java脚本API。

You can do it by using HTML5 FileAPI . 您可以使用HTML5 FileAPI来实现 But it is neccessary, that u or user should select the file for reading. 但是您或用户必须选择要读取的文件。 After uploading file, remains only to parse the necessary variables in the correct manner. 上传文件后,仅用于以正确的方式解析必要的变量。 Short example: 简短示例:

 function readSingleFile(e) { var file = e.target.files[0]; if (!file) { return; } var reader = new FileReader(); reader.onload = function(e) { var contents = e.target.result; displayContents(contents); }; reader.readAsText(file); } function displayContents(contents) { var element = document.getElementById('file-content'); element.innerHTML = contents; } document.getElementById('file-input') .addEventListener('change', readSingleFile, false); 
 <input type="file" id="file-input" /> <h3>Contents of the file:</h3> <pre id="file-content"></pre> 

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

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