<commit_before>{% extends 'DroneMapBundle::layout.html.twig' %}

{% block body_map %}
	<h1>Carte du monde</h1>
    <input id="search_query" name="search_query" type="text" value="11 avenue des iles d'or, 83400, Hyères">
    <input id="search" name="search" type="button" value="Rechercher">
    <a href="#" id="rectangleChoice" class="btn btn-default btn-lg" role="button">Détourer votre terrain</a>
    <div id='map'></div>
{% endblock %}

{% block javascripts_map %}
<script>
	$(function(){
		var credentialsKey = "<KEY>";
		var mapOptions = {
			credentials: credentialsKey,
			center: new Microsoft.Maps.Location(48.85720336058152, 2.3527531137302393),
			mapTypeId: Microsoft.Maps.MapTypeId.automatic,
			zoom: 10
		};

		var map = new Microsoft.Maps.Map(document.getElementById("map"), mapOptions);

		//Ajout de modules utilisés
		var handleClick = false;
        search_engine_loaded = false;
        Microsoft.Maps.loadModule('Microsoft.Maps.Search', { callback: function(){
        		search_engine_loaded = true;
	        }
	    });

        $("#search").click(function(){
        	var query = $("#search_query").val();
        	if(query != ""){
        		searchModule(query);
        	}
        });

        $("#rectangleChoice").click(function(e){
        	e.preventDefault();
        	$(this).toggleClass('active').trigger('classChange');
        	return false;
        });

		$(document).on('classChange', function(){
			if($("#rectangleChoice").hasClass('active')){
				handleClick = Microsoft.Maps.Events.addHandler(map, 'click', function(e){
					if (e.targetType == "map") {
						var point = new Microsoft.Maps.Point(e.getX(), e.getY());
						var loc = e.target.tryPixelToLocation(point);
						alert(loc.latitude + ", " + loc.longitude);
					}
				});
	        }else{
	        	if(handleClick !== false){
	        		Microsoft.Maps.Events.removeHandler(handleClick);
	        		handleClick = false;
	        	}
	        }
        });
        /*==========  Fonctions  ==========*/

		function searchModule(q)
		{
			if(search_engine_loaded){
				var searchManager = new Microsoft.Maps.Search.SearchManager(map);

				var searchRequest = {
					where: q, 
					count: 5, 
					callback: searchGeoCallback, 
					errorCallback: searchError
				};

				searchManager.geocode(searchRequest);
			}
		}

		function searchGeoCallback(geocodeResult, userData){
			map.setView({
				bounds: geocodeResult.results[0].bestView
			});
		}

		function searchError(searchRequest)
		{
			alert("An error occurred.");
		}
	});
</script>
{% endblock %}<commit_msg>Ajout du module de forme<commit_after>{% extends 'DroneMapBundle::layout.html.twig' %}

{% block body_map %}
	<h1>Carte du monde</h1>
    <input id="search_query" name="search_query" type="text" value="11 avenue des iles d'or, 83400, Hyères">
    <input id="search" name="search" type="button" value="Rechercher">
    <a href="#" id="rectangleChoice" class="btn btn-default btn-lg" role="button">Détourer votre terrain</a>
    <div id='map'></div>
{% endblock %}

{% block javascripts_map %}
<script>
	$(function(){
		var credentialsKey = "<KEY>";
		var mapOptions = {
			credentials: credentialsKey,
			center: new Microsoft.Maps.Location(48.85720336058152, 2.3527531137302393),
			mapTypeId: Microsoft.Maps.MapTypeId.automatic,
			zoom: 10
		};

		var map = new Microsoft.Maps.Map(document.getElementById("map"), mapOptions);

		//Ajout de modules utilisés
		var handleClick = false;
        search_engine_loaded = false;
        Microsoft.Maps.loadModule('Microsoft.Maps.Search', { callback: function(){
        		search_engine_loaded = true;
	        }
	    });
	    Microsoft.Maps.loadModule('Microsoft.Maps.AdvancedShapes', { callback: shapesModuleLoaded });

        $("#search").click(function(){
        	var query = $("#search_query").val();
        	if(query != ""){
        		searchModule(query);
        	}
        });

        $("#rectangleChoice").click(function(e){
        	e.preventDefault();
        	$(this).toggleClass('active').trigger('classChange');
        	return false;
        });

		$(document).on('classChange', function(){
			if($("#rectangleChoice").hasClass('active')){
				handleClick = Microsoft.Maps.Events.addHandler(map, 'click', function(e){
					if (e.targetType == "map") {
						var point = new Microsoft.Maps.Point(e.getX(), e.getY());
						var loc = e.target.tryPixelToLocation(point);
						alert(loc.latitude + ", " + loc.longitude);
					}
				});
	        }else{
	        	if(handleClick !== false){
	        		Microsoft.Maps.Events.removeHandler(handleClick);
	        		handleClick = false;
	        	}
	        }
        });
        /*==========  Fonctions  ==========*/

		function searchModule(q)
		{
			if(search_engine_loaded){
				var searchManager = new Microsoft.Maps.Search.SearchManager(map);

				var searchRequest = {
					where: q, 
					count: 5, 
					callback: searchGeoCallback, 
					errorCallback: searchError
				};

				searchManager.geocode(searchRequest);
			}
		}

		function searchGeoCallback(geocodeResult, userData){
			map.setView({
				bounds: geocodeResult.results[0].bestView
			});
		}

		function searchError(searchRequest)
		{
			alert("An error occurred.");
		}

		function shapesModuleLoaded()
		{
			var polygonWithHoles = new Microsoft.Maps.Polygon(
			[
				[new Microsoft.Maps.Location(47.604, -121.940),
				new Microsoft.Maps.Location(47.604, -121.540),
				new Microsoft.Maps.Location(47.834, -121.540),
				new Microsoft.Maps.Location(47.834, -121.940),
				new Microsoft.Maps.Location(47.604, -121.940)],
				[new Microsoft.Maps.Location(47.704, -121.740),
				new Microsoft.Maps.Location(47.704, -121.640),
				new Microsoft.Maps.Location(47.804, -121.640),
				new Microsoft.Maps.Location(47.804, -121.740),
				new Microsoft.Maps.Location(47.704, -121.740)],
				[new Microsoft.Maps.Location(47.744, -121.700),
				new Microsoft.Maps.Location(47.744, -121.680),
				new Microsoft.Maps.Location(47.764, -121.680),
				new Microsoft.Maps.Location(47.764, -121.700),
				new Microsoft.Maps.Location(47.744, -121.700)]
			]);

			map.entities.push(polygonWithHoles);

		}
	});
</script>
{% endblock %}
{'fraction_non_alphanumeric': 0.1632321921142301, 'fraction_numerical': 0.04170047055005679, 'mean_word_length': 3.071334214002642, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '12892', 'n_tokens_mistral': 2458, 'n_tokens_neox': 1994, 'n_words': 345}