I
I
ilya u2016-04-18 19:03:20
JavaScript
ilya u, 2016-04-18 19:03:20

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();
    });

2. The horizontal scroll is looped, the map can be rotated indefinitely. How to get rid of repetition? I did not find anywhere where you can insert no-repeate.
p.s. I haven't studied JS until now.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ilya u, 2016-04-21
@DasIstGlitch

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 question

Ask a Question

731 491 924 answers to any question