Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waypoint name #66

Open
1stgongsin opened this issue Feb 21, 2019 · 8 comments
Open

waypoint name #66

1stgongsin opened this issue Feb 21, 2019 · 8 comments

Comments

@1stgongsin
Copy link

When loading gpx file, waypoints just appear as circle.
Can it be possible that 'waypoint name' appears?

@leplatrem
Copy link
Collaborator

Can it be possible that 'waypoint name' appears?

Yes I think so, try to inspect the layer object you obtain from the loaded event:

var control = L.Control.fileLayerLoad();
    control.loader.on('data:loaded', function (event) {
        // event.layer gives you access to the layers you just uploaded!
        // iterate each point of the layer
        // add a popup or something with the layer properties
    });

@1stgongsin
Copy link
Author

1stgongsin commented Feb 22, 2019

Thank you for reply, leplatrem.
Sadly, I don't know about javascript at all. so I can't change the original code.

</docs/index.js>

    L.Control.FileLayerLoad.LABEL = '<img class="icon" src="folder.svg" alt="file icon"/>';
    control = L.Control.fileLayerLoad({
        fitBounds: true,
        layerOptions: {
            style: style,
           pointToLayer: function (data, latlng) {
              return L.circleMarker(
                   latlng,
                    { style: style }

                );
            }
        }
    });
    control.addTo(map);
    control.loader.on('data:loaded', function (e) {
        var layer = e.layer;
        console.log(layer);
    });
}

window.addEventListener('load', function () {
    initMap();
});

}(window));

[L.circleMarker] shows waypoint as just red circle. I want waypoint name appear
Can you teach me what code should I add to the original index.js ?

@johnd0e
Copy link

johnd0e commented Mar 27, 2019

Add this to layerOptions:

        layerOptions: {
          onEachFeature: function (feature, layer) {
            if (feature.properties.name) { layer.bindTooltip(feature.properties.name, { permanent: true }); }
          },
         // style: style,

@1stgongsin
Copy link
Author

Thank you for reply, johnd0e.

I changed code like below. but It's not working

    control = L.Control.fileLayerLoad({
        fitBounds: true,
        layerOptions: {
			          onEachFeature = function (feature, layer) {
                      if (feature.properties.name) { layer.bindTooltip(feature.properties.name, { permanent: true });
      },
            // style: style,
            pointToLayer: function (data, latlng) {
                return L.circleMarker(
                    latlng,
                    { style: style }
                );
            }
        }
    });
    control.addTo(map);

@johnd0e
Copy link

johnd0e commented Mar 28, 2019

There is mistype: change onEachFeature = to onEachFeature:

@1stgongsin
Copy link
Author

It doesn't work either. sorry for bothering
syntax error -> Unexpected token ,

    control = L.Control.fileLayerLoad({
        fitBounds: true,
        layerOptions: {
			
      onEachFeature: function (feature, layer) {
        if (feature.properties.name) { layer.bindTooltip(feature.properties.name, { permanent: true });
      },
     // style: style,

           pointToLayer: function (data, latlng) {
              return L.circleMarker(
                   latlng,
                    { style: style }

                );
            }
        }
    });

@johnd0e
Copy link

johnd0e commented Mar 28, 2019

control = L.Control.fileLayerLoad({
	fitBounds: true,
	layerOptions: {
		onEachFeature: function (feature, layer) {
        		if (feature.properties.name) { layer.bindTooltip(feature.properties.name, { permanent: true }) };
		},
		// style: style,
		pointToLayer: function (data, latlng) {
			return L.circleMarker(latlng, {style: style});
		}
	}
});

@geo903
Copy link

geo903 commented Aug 9, 2020

control1 = L.Control.fileLayerLoad({
            fitBounds: true,

            layerOptions: {
                onEachFeature: function (feature, layer) {
                     layer.bindTooltip(feature.properties.name, { permanent: true })
                },
                // style: style,


                    pointToLayer: function (feature, latlng) {
                        label = String(feature.properties.name); // .bindTooltip can't use straight 'feature.properties.attribute'
                        return new L.CircleMarker(latlng, {
                            weight: 0, fillOpacity:0
                        }).bindTooltip(label, {permanent: true, opacity: 1, direction: 'center',className: 'labelstyle'}).openTooltip();
                    }

            }

        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants