Answer the question
In order to leave comments, you need to log in
How to load markers from csv on an interactive map and fix them from repeating?
Hello. Recently started work on an interactive building floor map based on the map from Perrygeo ( leaflet-simple-csv ).
There are several questions, but in order not to produce a lot of topics, here I will ask two at once:
1. "Error retrieving csv file". CSV table is not defined immediately after unpacking the source. I tried to recreate the table, change the path to it, but in vain.
A piece of code from app.js responsible for adding markers:
map.addLayer(markers);
$(document).ready( function() {
$.ajax ({
type:'GET',
dataType:'text',
url: dataUrl,
contentType: "text/csv; charset=utf-8",
error: function() {
alert('Error retrieving csv file');
},
success: function(csv) {
dataCsv = csv;
populateTypeAhead(csv, fieldSeparator);
typeAheadSource = ArrayToSet(typeAheadSource);
$('#filter-string').typeahead({source: typeAheadSource});
addCsvMarkers();
}
});
$("#clear").click(function(evt){
evt.preventDefault();
$("#filter-string").val("").focus();
addCsvMarkers();
});
Answer the question
In order to leave comments, you need to log in
1. The problem was in the browser. Javascript makes an XMLHTTP request to get the CSV file. Some browsers cannot accept such requests for the file:// protocol (if the file is opened from the local machine). Opera, Chrome, IE are among them. With FireFox the csv file opened.
2. Add " noWrap: true " attribute to L.TileLayer . For more precise trimming, experiment with Bounds.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question