3

I have a web app based on this template https://github.com/bmcbride/bootleaf The app works fine with point geometry but I would like each feature to have a point and a polygon.

The geojson is:

{ "type": "Feature", "properties": { "id": 1, "Name": "Name", "Reference": "123456789", "Address": "Street, Address", }, "geometry": { "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [ -0.2340171, 51.4917468 ] }, { "type": "Polygon", "coordinates": [ [ [ -0.2343982458114624, 51.49143757352254 ], [ -0.23387789726257327, 51.491379122503375 ], [ -0.233859121799469, 51.49144091357853 ], [ -0.23383498191833493, 51.49144091357853 ], [ -0.23364990949630737, 51.49221913995003 ], [ -0.23423194885253903, 51.49227424989754 ], [ -0.23440629243850708, 51.491506044621154 ], [ -0.2343848347663879, 51.49150103454424 ], [ -0.2343982458114624, 51.49143757352254 ] ] ] } ] } }

The relevent part of the app:

var G1Layer = L.geoJson(null);
var G1s = L.geoJson(null, {
    pointToLayer: function(feature, latlng) {
        return L.marker(latlng, {
            icon: L.ExtraMarkers.icon({
                icon: 'fa-info',
                markerColor: 'red',
                shape: 'square',
                prefix: 'fa'
            }),

        title: feature.properties.S106,
        riseOnHover: true
    });
    },
    onEachFeature: function(feature, layer) {
        if (feature.properties) {
            var content = "<table class='table table-striped table-bordered table-condensed'>" + "<tr><th>Name</th><td>" + feature.properties.name + "</td></tr>" + "<tr><th>Reference</th><td>" + feature.properties.reference + "</td></tr>" + "<table>";

            layer.on({
                click: function(e) {
                    $("#feature-title").html(feature.properties.S106);
                    $("#feature-info").html(content);
                    $("#featureModal").modal("show");
                    highlight.clearLayers().addLayer(L.circleMarker([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], highlightStyle));
                }
            });
            $("#feature-list tbody").append('<tr class="feature-row" id="' + L.stamp(layer) + '" lat="' + layer.getLatLng().lat + '" lng="' + layer.getLatLng().lng + '"><td style="vertical-align: middle;"><i class="fa fa-info" style="font-size:12px;color:red ;"></td><td class="feature-name">' + layer.feature.properties.name + '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
            G1Search.push({
                name: layer.feature.properties.name,
                address: layer.feature.properties.Address,
                source: "G1s",
                id: L.stamp(layer),
                lat: layer.feature.geometry.coordinates[1],
                lng: layer.feature.geometry.coordinates[0]
            });
        }
    }
});
$(document).ready(function() {
    G1s.addData(G1Data);
   map.addLayer(G1Layer);
});

closed as off-topic by IvanSanchez, nmtoken, BERA, aldo_tapia, Kersten Nov 28 '17 at 13:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – IvanSanchez, nmtoken, BERA, aldo_tapia, Kersten
If this question can be reworded to fit the rules in the help center, please edit the question.

  • That GeoJSON works for me. What's the problem, exactly? – IvanSanchez Nov 28 '17 at 8:09
  • I'm having a problem combining a marker and a polygon for the same feature or at the very least substituting markers in github.com/bmcbride/bootleaf with polygons. thanks – MoG Nov 29 '17 at 10:16