0

I have a series of circles and lines representing some information about a geographical location. Is it possible to reuse that (complex) geometry by simply attaching it to a single point?

In other words, I would like to use that set (of geometries) as a prototype geometry for other locations, is that possible?

series of circles + a polyline as an example

  • What do you exactly mean by "prototype geometry"? Can you give an example? – IvanSanchez Mar 9 '17 at 16:54
  • I mean a series of geometries (circles, lines, polygons) ensembled together in a layer group to graphically represent a feature. – Gamze Mar 13 '17 at 12:53
  • Like a glyph? You might want to use L.Markers for those. – IvanSanchez Mar 13 '17 at 13:41
  • No, it is not like glyph. I use L.circle multiple times. And then I group those circles. And I repeat this process for different points. So, I search for a solution where those group of circles could be called to assign a different geographical coordinate. – Gamze Mar 13 '17 at 14:30
  • Could you post a screenshot or diagram of how these work? I find it difficult to understand what you exactly mean. – IvanSanchez Mar 14 '17 at 8:39
1

If i understand you correctly, yes it is easy to re-use something complex with...functional abstraction !

This would look like :

function createMyComplexThingAt(lat, lon) {
    // a circle centered where you asked the complex thing
    var circle1 = L.circle([lat, lon], 8);
    // a circle which is on the top left
    var circle2 = L.circle([lat + 0.02, lon + 0.05], 8);
    // etc...
    // until
    var lgroup = L.layerGroup([circle1, circle2]);

    return lgroup;
}

var lgroup1 = createMyComplexThingAt(30, 44);
var lgroup2 = createMyComplexThingAt(21, 2);
var lgroup3 = createMyComplexThingAt(0.33, 5.44);

You can even give more parameters to your complex thing as a title text that would be used in popup or whatever you can think of.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.