Bonjour à tous,

Déjà veuillez m'excuser si je me suis tromper de catégorie.

Voilà je voudrais importer en Javascript un fichier KML créé à partir d'un fichier PHP qui fait appelles à plusieurs donnée stockées dans une base de donnée.

Le soucis c'est que du moins je pense, qu'il y a trop de marqueur, 1000 à peu près... Et je sais pas du tout si le problème vient du cache généré par Google lors de la création du KML ou de mon Serveur, les marqueurs ne s'affichent pas tout le temps...

Index.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15">
<title>Géo-localisation</title>
<link rel="stylesheet" media="screen" href="style/style.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
 
<?php
        
        echo'
                <script type="text/javascript">
                $(document).ready( function(){
                        var latlng = new google.maps.LatLng(45.093035,2.663455);
                        var options = {
                                center: latlng,
                                zoom: 9,
                                scrollwheel: true,
                                mapTypeId: google.maps.MapTypeId.TERRAIN
                        };
                        
                        var carte = new google.maps.Map(document.getElementById("carte"), options);
                        
                        var layer = new google.maps.KmlLayer("http://stagius.cantal.fr/gm/newkml.php");
                        layer.setMap(carte);
                });
                </script>
        ';
?>
</head>
<body>
<div id="carte"></div>
</body>
</html>
kml.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
 
<?php
        mysql_connect("****","****","****") ;
        mysql_select_db("****") ;
        mysql_query("SET NAMES 'utf8'");
 
        header('Content-type: application/vnd.google-earth.kml+xml'); 
        header("Content-Disposition: attachment; filename=location.kml");
        echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
 
<kml xmlns="http://earth.google.com/kml/2.2">
	<Document>
 
		<name>
			<![CDATA[]]>
		</name>
 
		<Style id="marqueurGeolocaliser">
			<IconStyle>
				<Icon>
					<href><![CDATA[http://www.google.com/intl/en_us/mapfiles/ms/micons/yellow-dot.png]]></href>
				</Icon>
			</IconStyle>
		</Style>
 
		<Style id="marqueurNonGeolocaliser">
			<IconStyle>
				<Icon>
					<href><![CDATA[http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png]]></href>
				</Icon>
			</IconStyle>
		</Style>
 
		<Style id="contourCantal">
			<LineStyle>
				<color>ff494a44</color>
				<width>3</width>
			</LineStyle>
			<PolyStyle>
				<fill>0</fill>
				<outline>1</outline>
				<color>00ffffff</color>
			</PolyStyle>
		</Style>
 
 
		<Placemark id="cantal"<?php
                        $r1 = "
                                SELECT 
                                a.id, a.vid_assmat, a.sexe_assmat, a.nom_assmat, a.prenom_assmat, a.adresse_assmat, a.adresse2_assmat, a.cp_assmat, a.ville_assmat, a.num_assmat, a.lat_assmat, a.lng_assmat, ag.nb_agr, ag.ageMini_agr, ag.ageMaxi_agr, ag.debut_agr, ag.fin_agr
                                FROM assmat a, agrement ag
                                WHERE ( a.lat_assmat != 0 AND a.lng_assmat != 0 AND a.lat_assmat BETWEEN 44.52112  AND 45.600347  AND a.lng_assmat BETWEEN 1.927414  AND 3.738556 ) AND a.vid_assmat = ag.id_assmat LIMIT 0,30
                        ";
                        
                        $q1 = mysql_query( $r1 ) ;
                        
                        $resQ1 = mysql_num_rows( $q1 );
                        
                        while ( $data1 = mysql_fetch_assoc( $q1 ) ){
                ?>
				<Placemark id="marqueur<?=$data1["id"]?>">
					<name><![CDATA[<?=$data1["prenom_assmat"]?>]]></name>
					<description><![CDATA[]]></description>
					<styleUrl>#marqueurGeolocaliser</styleUrl>
					<Point>
						<coordinates><?=$data1["lng_assmat"]?>,<?=$data1["lat_assmat"]?></coordinates>
					</Point>
				</Placemark>
		<?php
                        }
                ?>
 
		<?php
                        $r2 = "
                                SELECT
                                a.id, a.vid_assmat, a.sexe_assmat, a.nom_assmat, a.prenom_assmat, a.adresse_assmat, a.adresse2_assmat, a.cp_assmat, a.ville_assmat, a.num_assmat, c.Lat, c.Lon, ag.nb_agr, ag.ageMini_agr, ag.ageMaxi_agr, ag.debut_agr, ag.fin_agr
                                FROM assmat a, com_co c, agrement ag
                                WHERE a.lat_assmat = 0 AND a.lng_assmat = 0 AND a.ville_assmat = c.nom AND a.vid_assmat = ag.id_assmat LIMIT 0,30
                        ";
                        
                        $q2 = mysql_query( $r2 );
                        
                        $resQ2 = mysql_num_rows( $q2 ) ;
                        
                        while ( $data2 = mysql_fetch_assoc( $q2 ) ){
                ?>
				<Placemark id="marqueur<?=$data2["id"]?>">
					<name><![CDATA[<?=$data2["prenom_assmat"]?>]]></name>
					<description><![CDATA[]]></description>
					<styleUrl>#marqueurNonGeolocaliser</styleUrl>
					<Point>
						<coordinates><?=$data2["Lon"]?>,<?=$data2["Lat"]?></coordinates>
					</Point>
				</Placemark>
		<?php
                        }
                ?>
 
		</Document>
</kml>