6
私はライブラリを使用してKMLを生成し、Googleマップにデータを表示しますが、 'Point'形状は機能していないため、KMLを生成しません。 ここでは、多角形のコードスニペットを使用して、ポイントシェイプの作成に役立ちます。PHP - 'Point'の形状からkmlを生成
//this shape data i'm fetching from shapefile library.
$shp_data = $record->getShpData();
if (isset($shp_data['parts'])) {
$counter1 = 0;
if ($shp_data['numparts']) {
$polygon_array['polygon']['status'] = 'multi-polygon';
} else {
$polygon_array['polygon']['status'] = 'single-polygon';
}
$polygon_array['polygon']['total_polygon'] = $shp_data['numparts'];
foreach ($shp_data['parts'] as $polygon) {
foreach ($polygon as $points) {
$counter = 0;
$polygon_string = '';
while ($counter < count($points)) {
if ($counter == 0) {
$polygon_string = $points[count($points) - 1]['x'] . ',';
$polygon_string .= $points[$counter]['y'] . ' ' . $points[$counter]['x'] . ',';
} else if ($counter == count($points) - 1) {
$polygon_string .= $points[$counter]['y'];
} else {
$polygon_string .= $points[$counter]['y'] . ' ' . $points[$counter]['x'] . ',';
}
$counter = $counter + 1;
}
$polygon_single[$counter1] = $polygon_string;
$polygon_array['polygon']['view'] = $polygon_single;
$counter1 = $counter1 + 1;
}
}
$arr[$i] = $polygon_array;
$i++;
}
代替ライブラリがありますか? – Rorschach
@Rorschach no、申し訳ありません – chrki