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
Customizing the marker #14
Comments
I guess you can use
|
Nice, I'll try. Thanks for the hint! |
See example 8 |
Thanks again, so I guess we can close here :) |
Maybe this should be easier via a property but maybe this is not so complex ... |
Hmmh, I do not get it working. The example seems to be too far away from what I need. I tried to modify the example but I'm e.g. unsure where to get the |
I did not check my code, but this should do: //init your data
var map=...:
var icon =...;
var geoJsonData = ...;
//declare a normal GeoJson layer
var geojsonLayer = L.geoJson(geoJsonData , {
pointToLayer: (function(feature, latLng) {
//check if it's the last point added
if (feature.properties.hasOwnProperty('last')) {
return new L.Marker(latLng, {
icon: icon
});
}
//else
return L.circleMarker(latLng, {
fillColor: 'red',
fillOpacity: 0.5,
stroke: false,
radius: 3
});
})
});
// Add time capability to the geojson layer
var geoJsonTimeLayer = L.timeDimension.layer.geoJson(geojsonLayer , {
addlastPoint: true
});
//add the timed layer to the map
geoJsonTimeLayer .addTo(map); |
Looks simpler then, thanks a lot! But still not working :( Not sure if my complication due to gpx makes this not working but with this code, it is still showing the default end marker as the 'pointToLayer' is never called: var gpxLayer = L.geoJson();
gpxLayer.pointToLayer = function (feature, latLng) {
if (feature.properties.hasOwnProperty('last')) {
return new L.Marker(latLng, {
icon: icon
});
}
//else
return L.circleMarker(latLng, {
fillColor: 'red',
fillOpacity: 0.5,
stroke: false,
radius: 3
});
};
gpxLayer = omnivore.gpx(url, null, gpxLayer).on('ready', function () {});
var geoJsonLayer = L.timeDimension.layer.geoJson(gpxLayer, {
updateTimeDimension: true,
addlastPoint: true
});
geoJsonLayer.addTo(map); And the GPX is necessary for the additional time information |
You are not passing it as option. L.geoJson(null, {
pointToLayer: function() {
// todo
}
}); |
Sorry, didn't mention it: this was my first try and was also without success... |
I think the plugin needs an update here to take into account the pointToLayer hook |
Uhm, my fault, sorry - there was some Here is the short and working code: var map = ...
var icon = ...
var icon2 = ...
var url = ...
var gpxLayer = omnivore.gpx(url).on('ready', function () {
});
gpxLayer.options = {
style: myStyle,
pointToLayer: function (feature, latLng) {
if (feature.properties.hasOwnProperty('last')) {
return new L.Marker(latLng, {
icon: icon
});
}
//else
return new L.Marker(latLng, {
icon: icon2
});
}
};
var geoJsonLayer = L.timeDimension.layer.geoJson(gpxLayer, {
updateTimeDimension: true,
addlastPoint: true
});
geoJsonLayer.addTo(map); |
Hi! I have update example 9, and now it appears a different marker. I think there is no need to add an option to timedimension, because in other cases you might need to modify other options of the geojson base layer. But I should modify the documentation, to explain that timedimension adds a special property Thanks @ram-one for your participation :-) |
Thanks @bielfrontera ! |
How can I change the marker of the 'current position' without overwriting the marker-icon.png :) ?
BTW: I'm speaking of the
addlastPoint: true
optionSomehow one needs to replace this with e.g. a custom marker:
The text was updated successfully, but these errors were encountered: