Change Theme & KML generator
-
Hello Webaware,
Can you explain me why my map disappear ?
https://www-test.comptoirdesentreprises.com/region/haute-normandie/
I use the KML Dom Generation
https://www-test.comptoirdesentreprises.com/region/haute-normandie/?feed=kmlregionrssI’m not sure about the function…
<?php // Creates the Document. $dom = new DOMDocument('1.0', 'UTF-8'); // Creates the root KML element and appends it to the root document. $node = $dom->createElementNS('https://earth.google.com/kml/2.1', 'kml'); $parNode = $dom->appendChild($node); // Creates a KML Document element and append it to the KML element. $dnode = $dom->createElement('Document'); $docNode = $parNode->appendChild($dnode); // Creates the two Style elements, one for standard and one for bar, and append the elements to the Document element. $strdStyleNode = $dom->createElement('Style'); $strdStyleNode->setAttribute('id', 'standardStyle'); $strdIconstyleNode = $dom->createElement('IconStyle'); $strdIconstyleNode->setAttribute('id', 'standardIcon'); $strdIconNode = $dom->createElement('Icon'); $strdHref = $dom->createElement('href', 'https://maps.google.com/mapfiles/kml/pal2/icon63.png'); $strdIconNode->appendChild($strdHref); $strdIconstyleNode->appendChild($strdIconNode); $strdStyleNode->appendChild($strdIconstyleNode); $docNode->appendChild($strdStyleNode); /* $barStyleNode = $dom->createElement('Style'); $barStyleNode->setAttribute('id', 'barStyle'); $barIconstyleNode = $dom->createElement('IconStyle'); $barIconstyleNode->setAttribute('id', 'barIcon'); $barIconNode = $dom->createElement('Icon'); $barHref = $dom->createElement('href', 'https://maps.google.com/mapfiles/kml/pal2/icon27.png'); $barIconNode->appendChild($barHref); $barIconstyleNode->appendChild($barIconNode); $barStyleNode->appendChild($barIconstyleNode); $docNode->appendChild($barStyleNode); */ $term_region = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $args = array( 'post_type' => 'visite', 'posts_per_page' => -1, //'p' => 2028, 'post_status' => 'any', 'orderby' => 'ASC', 'tax_query' => array( array( 'taxonomy' => 'tax_region', 'field' => 'slug', //'terms' => 'alsace', 'terms' => $term_region->slug, ) ), ); $posts = new wp_query( $args ); $posts = $posts->posts; //var_dump($posts); //die(); // Iterates through the MySQL results, creating one Placemark for each row. foreach( $posts as $post ) { setup_postdata( $post ); $location = get_post_meta( $post->ID, 'adress_factory_map', true ); if($location != ''){ // Creates a Placemark and append it to the Document. $node = $dom->createElement('Placemark'); $placeNode = $docNode->appendChild($node); // Creates an id attribute and assign it the value of id column. $placeNode->setAttribute('id', 'placemark' . $post->ID); // Create name, and description elements and assigns them the values of the name and address columns from the results. $nameNode = $dom->createElement('name',htmlentities($post->post_title)); $placeNode->appendChild($nameNode); $descNode = $dom->createElement('description', $location["address"]); $placeNode->appendChild($descNode); //$styleUrl = $dom->createElement('styleUrl', '#' . $row['type'] . 'Style'); $styleUrl = $dom->createElement('styleUrl', '#standardStyle'); $placeNode->appendChild($styleUrl); // Creates a Point element. $pointNode = $dom->createElement('Point'); $placeNode->appendChild($pointNode); // Creates a coordinates element and gives it the value of the lng and lat columns from the results. $coorStr = $location['lng'] . ',' . $location['lat']; $coorNode = $dom->createElement('coordinates', $coorStr); $pointNode->appendChild($coorNode); } } $kmlOutput = $dom->saveXML(); header('Content-type: application/vnd.google-earth.kml+xml'); echo $kmlOutput; ?>
Thank you.
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Change Theme & KML generator’ is closed to new replies.