Rackal
Rackal

Reputation: 1

Google maps pins import from .txt

var gmarkers1 = [];
var markers1 = [];
var infowindow = new google.maps.InfoWindow({
    content: ''
});
markers1 = [
    ['0', 'Title', 52.4357808, 4.991315699999973, 'car'],
    ['1', 'Title', 52.4357808, 4.981315699999973, 'third'],
    ['2', 'Title', 52.4555687, 5.039231599999994, 'car'],
    ['3', 'Title', 52.4555687, 5.029231599999994, 'second']
];

I found this script, how can I import data from .txt files into markers1?

And second, how can I show my select on text with document.getElementById?

I show only title, like this, if I choose "car" to show only the title:

<div id="map-canvas"></div>
<select id="type" onchange="filterMarkers(this.value);">
    <option value="">Please select category</option>
    <option value="second">second</option>
    <option value="car">car</option>
    <option value="third">third</option>
</select>
full script here Google Map Pins - Filter by category

Upvotes: -2

Views: 320

Answers (1)

Rackal
Rackal

Reputation: 1

I have tried the following code

filterMarkers = function (category) {
    for (i = 0; i < markers1.length; i++) {
        marker = gmarkers1[i];
        // If is same category or category not picked
        if (marker.category == category || category.length === 0) {
            marker.setVisible(true);
        }
        // Categories don't match 
        else {
            marker.setVisible(false);
        }
        document.getElementById("demo").innerHTML = "You selected: " + marker[];
    }
<p id="demo"></p>

but it throws me [object]

To read from txt I can not convey it in some way. The file will be in a file server

Thank you for your time!

Upvotes: 0

Related Questions