3

I have created polygon using two way but i have not understand difference between them.

  1. using grid layer

    http://bl.ocks.org/rclark/7043524

  2. using feature layer......

    L.mapbox.accessToken = 'pk.eyJ1IjoiZ2F1cmF2Y2F0c3RlY2giLCJhIjoiY2l1cGo0MTl4MDAxajJ1bng5a2xieTY0diJ9.0fDXNulI91U85ngSc4jGCg';
    
    var map = L.mapbox.map('map')
    .setView([38.89399, -77.03659], 17);
    
    L.mapbox.styleLayer('mapbox://styles/gauravcatstech/civ82vos7008f2is5x92cpvye').addTo(map);
    
    var featureGroup = L.featureGroup().addTo(map);
    var circle_options = {
        color: '#fff',      // Stroke color
        opacity: 1,         // Stroke opacity
        weight: 10,         // Stroke weight
        fillColor: '#000',  // Fill color
        fillOpacity: 0.6    // Fill opacity
    };
    
    var line_points = [
        [38.893596444352134, -77.0381498336792],
        [38.89337933372204, -77.03792452812195],
        [38.89316222242831, -77.03761339187622],
        [38.893028615148424, -77.03731298446655],
        [38.892920059048464, -77.03691601753235],
        [38.892903358095296, -77.03637957572937],
        [38.89301191422077, -77.03592896461487],
        [38.89316222242831, -77.03549981117249],
        [38.89340438498248, -77.03514575958252],
        [38.893596444352134, -77.0349633693695]
    ];
    
    var polyline_options = {
        color: '#000'
    };
    
    var polyline = L.polygon(line_points, polyline_options).addTo(featureGroup);
    
    var drawControl = new L.Control.Draw({
        edit: {
            featureGroup: featureGroup
        }
    }).addTo(map);
    
    map.on('draw:created', function(e) {
        featureGroup.addLayer(e.layer);
    });
    
2
  • if i do like this.. var map = L.mapbox.map('map', 'rclark.h2jc29lj', { gridControl: false, }).setView([36.18111, -110.44555], 9); myLayer = L.mapbox.featureLayer().addTo(map); var states=data_1; myLayer.setGeoJSON(states); Commented Nov 30, 2016 at 12:24
  • it shows the polygon .....then why we are using gridlayer in first example Commented Nov 30, 2016 at 12:26

1 Answer 1

2

In the first case the polygon data is in GeoJSON tiles, and in the second case the data is defined inline in the JS code.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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