|
Besson Thierry - 2014-03-14 11:55:51
Hello,
I'm french, sorry for my english
How can I added the polygon and color?
How to make a side menu which lists the various geomarkers that comes from mysql
Thnx in advance,
Bonjour,
Comment puis je rajouté des polygon?
Comment faire un menu sur le coté qui liste les différents geomarkers qui provient de mysql
Vagharshak Tozalakyan - 2014-03-16 09:21:00 - In reply to message 1 from Besson Thierry
Please download the latest version and check Example 11.
Besson Thierry - 2014-03-18 19:20:13 - In reply to message 2 from Vagharshak Tozalakyan
Thank you very much. For polygons I had succeeded in doubling the _polylines code and replace it with _polygons.
The menu on the side, great :)
I still allow a question.
Polygons come from 2 mysql tables
The first one contains some markers with its coordinates, color, and miscellaneous information
SQL table structure
id, id_marker, lat, lng, color, ico, col1, col2
The second table contains the polygon points which are associated to a marker "id_marker"
SQL table structure
id, id_marker, lat, lng
I use a first loop that built my array of points for the polygon
The second to display the polygon with associated color.
The problem is that I find no solution to the two bonded id_marker I have but I do not know how to use it.
Vagharshak Tozalakyan - 2014-03-18 19:37:31 - In reply to message 3 from Besson Thierry
Can you please clarify/elaborate your question? I do not understand why you use 2 tables to keep coordinates and what is meant by "two bonded id_marker".
Besson Thierry - 2014-03-18 22:29:53 - In reply to message 4 from Vagharshak Tozalakyan
je ne sais pas comment expliquer.
je ne parviens pas à faire le liaison entre les deux boucles.
I do not know how to explain.
I can not make the connection between the two loops.
$path = $path1 = $path2 = array();
$query_Recordset1 = "SELECT id_polygon,lat,lng FROM `polygon`";
$Recordset1 = mysql_query($query_Recordset1) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)){
$path = array($row_Recordset1['lat'],$row_Recordset1['lng']);
}
$query_Recordset2 = "SELECT id_polygon,color FROM `Fiche_culture`";
$Recordset2 = mysql_query($query_Recordset2) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
do {
$map->addPolygon($path, $row_Recordset2['color'], $row_Recordset2['color'],2, 1.0,0.35);
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
je vais essayé de trouver une personne pour m'aidé en anglais. lol
Vagharshak Tozalakyan - 2014-03-18 23:08:12 - In reply to message 5 from Besson Thierry
Did you mean something like this?
<?php
$polygons = array();
$result = mysql_query("SELECT t1.polygon_id, t1.lat, t1.lng, t2.color FROM polygon AS t1, Fiche_culture AS t2 WHERE t1.polygon_id = t2.polygon_id") or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
if (!isset($polygons[$row['polygon_id']])) {
$polygons[$row['polygon_id']] = array(
'color' => $row['color'],
'path' => array()
);
}
$polygons[$row['polygon_id']]['path'][] = array($row['lat'], $row['lng']);
}
print_r($polygons);
?>
Besson Thierry - 2014-03-19 09:46:34 - In reply to message 6 from Vagharshak Tozalakyan
Yes it is a little of what I want to do.
By cons when I send $ polygons in the class for display
I get this:
path: [
google.maps.LatLng new (4, 4)
new google.maps.LatLng (-, 0)
]
<?php
$polygons = array();
$result = mysql_query("SELECT t1.polygon_id, t1.lat, t1.lng, t2.color FROM polygon AS t1, Fiche_culture AS t2 WHERE t1.polygon_id = t2.polygon_id") or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
if (!isset($polygons[$row['polygon_id']])) {
$polygons[$row['polygon_id']] = array(
'color' => $row['color'],
'path' => array()
);
}
//$polygons[$row['polygon_id']]['path'][] = array($row['lat'], $row['lng']);
$map->addPolygon($polygons[$row['polygon_id']]['path'][] = array($row['lat'], $row['lng']), $polygons[$row['polygon_id']]['color'], $polygons[$row['polygon_id']]['color'],2, 1.0,0.35);
}
//print_r($polygons);
?>
Vagharshak Tozalakyan - 2014-03-19 11:10:17 - In reply to message 7 from Besson Thierry
<?php
$polygons = array();
$result = mysql_query("SELECT t1.polygon_id, t1.lat, t1.lng, t2.color FROM polygon AS t1, Fiche_culture AS t2 WHERE t1.polygon_id = t2.polygon_id") or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
if (!isset($polygons[$row['polygon_id']])) {
$polygons[$row['polygon_id']] = array(
'color' => $row['color'],
'path' => array()
);
}
$polygons[$row['polygon_id']]['path'][] = array($row['lat'], $row['lng']);
}
foreach ($polygons as $polygon) {
$map->addPolygon($polygon['path'], $polygon['color'], $polygon['color'], 2, 1.0, 0.35);
}
?>
Vagharshak Tozalakyan - 2014-03-19 11:16:36 - In reply to message 8 from Vagharshak Tozalakyan
<?php
$polygons = array();
$result = mysql_query("SELECT t1.polygon_id, t1.lat, t1.lng, t2.color FROM polygon AS t1, Fiche_culture AS t2 WHERE t1.polygon_id = t2.polygon_id") or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
if (!isset($polygons['p-' . $row['polygon_id']])) {
$polygons['p-' . $row['polygon_id']] = array(
'color' => $row['color'],
'path' => array()
);
}
$polygons['p-' . $row['polygon_id']]['path'][] = array($row['lat'], $row['lng']);
}
foreach ($polygons as $polygon) {
if (sizeof($polygon['path'])) {
$map->addPolygon($polygon['path'], $polygon['color'], $polygon['color'], 2, 1.0, 0.35);
}
}
?>
|