Markers on google maps uploaded from excel(xlsx) file using Javascript -


i looking solution app. need upload excel file data , show data file on google maps multiple markers. found solution second part (show multiple markers on google map):

 <script>    function initialize() {     var mapdiv = document.getelementbyid('mymap');     var mapoptions = {                 center: new google.maps.latlng (-33.865143, 151.209900),       zoom: 12,       maptypeid: google.maps.maptypeid.roadmap     };      var map = new google.maps.map(mapdiv, mapoptions);      var locations = [];     locations.push ({name:"bondi beach", latlng: new google.maps.latlng(-33.890542, 151.274856)});     locations.push ({name:"coogee beach", latlng: new google.maps.latlng(-33.923036, 151.259052)});     locations.push ({name:"cronulla beach", latlng: new google.maps.latlng(-34.028249, 151.157507)});     locations.push ({name:"manly beach", latlng: new google.maps.latlng(-33.80010128657071, 151.28747820854187)});      (var = 0; < locations.length; i++) {       var marker = new google.maps.marker({position: locations[i].latlng, map:map, title:locations[i].name});     }   }    window.onload = initialize;  </script> 

but how can upload data excel(i want user submit file data) , use show markers?
totally new programming, appreciated :)

you can use sheetjs parse excel files in javascript. have 2 seperate versions .xls , .xlsx files.

you can load excell sheet using ajax. if want directly parse excel sheet user inputs, can use filereader object , .readasbinarystring() method.

document.getelementbyid("excel").addeventlistener("change", function(e) {      var file = e.target.files[0];        //verify selected file supported worksheet file.      //you can check file.name , file.type properties validation        var reader = new filereader();        reader.onload = function(e) {          var data = e.target.result;            /* if binary string, read type 'binary' */          var workbook = xls.read(data, {              type: 'binary'          });                    console.log(workbook.sheets[workbook.sheetnames[0]]["a1"].v); //read value of a1 cell in first worksheet          /* workbook here */      };      reader.readasbinarystring(file);  });
<script src="https://cdnjs.cloudflare.com/ajax/libs/xls/0.7.5/xls.full.min.js"></script>  <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/xlsx.full.min.js"></script>    <input type="file" id="excel" />


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -