<commit_before>{% load i18n static mapentity leaflet_tags geojson_tags %}

{% leaflet_map "detailmap"  fitextent=False callback="detailmapInit" %}
<script type="text/javascript">
function detailmapInit(map, bounds) {
    {% smart_include "mapinit" %}   // Each app can add layers etc.

    {% if readonly %}
        // Set map readonly
        map.dragging.disable();
        map.touchZoom.disable();
        map.doubleClickZoom.disable();
        map.scrollWheelZoom.disable();
        map.boxZoom.disable();
    {% endif %}
    map.removeControl(map.zoomControl);
    map.removeControl(map.attributionControl);

    var DETAIL_STYLE = L.Util.extend(window.SETTINGS.map.styles.detail, {clickable: false});

    // Add layers
    var geojson = {{ object|geojsonfeature|safe }};
    var objectLayer = new L.ObjectsLayer(geojson, {
        style: DETAIL_STYLE,
        indexing: false
    });
    map.addLayer(objectLayer);
    map.on('layeradd', function () {
        objectLayer.bringToFront();
    })

    var objectBounds = {{ object|latlngbounds }},
        mapBounds = objectBounds ? new L.LatLngBounds(objectBounds) : bounds;
    map.fitBounds(mapBounds);


    // Show start and end
    objectLayer.eachLayer(function (layer) {
        if (layer instanceof L.MultiPolyline)
            return;
        if (typeof layer.getLatLngs != 'function')  // points
            return;

        L.marker(layer.getLatLngs()[0],
                 {clickable: false,
                  icon: new L.Icon.Default({iconUrl: '{% static "mapentity/images/osrm_markers/marker-source.png" %}'})
                 }).addTo(map);
        L.marker(layer.getLatLngs().slice(-1)[0],
                 {clickable: false,
                  icon: new L.Icon.Default({iconUrl: '{% static "mapentity/images/osrm_markers/marker-target.png" %}'})
                 }).addTo(map);

        // Also add line orientation
        layer.setText('>     ', {repeat:true, 
                                 offset: DETAIL_STYLE.weight,
                                 attributes: {'fill': DETAIL_STYLE.arrowColor, 'font-size': DETAIL_STYLE.arrowSize}});
    });

    // Restore map context, only for screenshoting purpose<commit_msg>Detail reset bounds around object<commit_after>{% load i18n static mapentity leaflet_tags geojson_tags %}

{% leaflet_map "detailmap"  fitextent=False callback="detailmapInit" %}
<script type="text/javascript">
function detailmapInit(map, bounds) {
    {% smart_include "mapinit" %}   // Each app can add layers etc.

    {% if readonly %}
        // Set map readonly
        map.dragging.disable();
        map.touchZoom.disable();
        map.doubleClickZoom.disable();
        map.scrollWheelZoom.disable();
        map.boxZoom.disable();
    {% endif %}
    map.removeControl(map.zoomControl);
    map.removeControl(map.attributionControl);

    var DETAIL_STYLE = L.Util.extend(window.SETTINGS.map.styles.detail, {clickable: false});

    // Add layers
    var geojson = {{ object|geojsonfeature|safe }};
    var objectLayer = new L.ObjectsLayer(geojson, {
        style: DETAIL_STYLE,
        indexing: false
    });
    map.addLayer(objectLayer);
    map.on('layeradd', function (e) {
        if (objectLayer._map) objectLayer.bringToFront();
    })

    var mapBounds = {{ object|latlngbounds }} || bounds;
    map.fitBounds(mapBounds);
    map.resetviewControl.getBounds = function () { return mapBounds; };


    // Show start and end
    objectLayer.eachLayer(function (layer) {
        if (layer instanceof L.MultiPolyline)
            return;
        if (typeof layer.getLatLngs != 'function')  // points
            return;

        L.marker(layer.getLatLngs()[0],
                 {clickable: false,
                  icon: new L.Icon.Default({iconUrl: '{% static "mapentity/images/osrm_markers/marker-source.png" %}'})
                 }).addTo(map);
        L.marker(layer.getLatLngs().slice(-1)[0],
                 {clickable: false,
                  icon: new L.Icon.Default({iconUrl: '{% static "mapentity/images/osrm_markers/marker-target.png" %}'})
                 }).addTo(map);

        // Also add line orientation
        layer.setText('>     ', {repeat:true, 
                                 offset: DETAIL_STYLE.weight,
                                 attributes: {'fill': DETAIL_STYLE.arrowColor, 'font-size': DETAIL_STYLE.arrowSize}});
    });

    // Restore map context, only for screenshoting purpose
{'fraction_non_alphanumeric': 0.13199458483754511, 'fraction_numerical': 0.002256317689530686, 'mean_word_length': 2.3813882532418003, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4736526', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1284, 'n_words': 252}