Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require("dbinfotanah.php");
- function parseToXML($htmlStr)
- {
- $xmlStr=str_replace('<','<',$htmlStr);
- $xmlStr=str_replace('>','>',$xmlStr);
- $xmlStr=str_replace('"','"',$xmlStr);
- $xmlStr=str_replace("'",''',$xmlStr);
- $xmlStr=str_replace("&",'&',$xmlStr);
- return $xmlStr;
- }
- // Opens a connection to a MySQL server
- $connection=mysqli_connect ('localhost', $username, $password, $database);
- if (!$connection) {
- die('Not connected : ' . mysqli_error());
- }
- // Set the active MySQL database
- $db_selected = mysqli_select_db($connection , $database);
- if (!$db_selected) {
- die ('Can't use db : ' . mysqli_connect_error());
- }
- // Select all the rows in the markers table
- $query = "SELECT * FROM table7 WHERE 1";
- $result = mysqli_query($connection , $query);
- if (!$result) {
- die('Invalid query: ' . mysqli_connect_error());
- }
- header("Content-type: text/xml");
- // Start XML file, echo parent node
- echo '<table_p>';
- // Iterate through the rows, printing XML nodes for each
- while ($row = @mysqli_fetch_assoc($result)){
- // Add to XML document node
- echo '<project ';
- echo 'Project="' . parseToXML($row['Project']) . '" ';
- echo 'Project2="' . parseToXML($row['Project2']) . '" ';
- echo 'Scope="' . $row['Scope'] . '" ';
- echo 'Area="' . $row['Area'] . '" ';
- echo 'Position="' . $row['Position'] . '" ';
- echo 'Company="' . $row['Company'] . '" ';
- echo 'Years="' . $row['Years'] . '" ';
- echo 'lat="' . $row['Lat'] . '" ';
- echo 'long="' . $row['Long'] . '" ';
- echo '/>';
- }
- // End XML file
- echo '</table_p>';
- ?>
- <?php
- $username="root";
- $password="";
- $database="dbtanah";
- ?>
- <script>
- function initMap() {
- var map = new google.maps.Map(document.getElementById('map'), {
- center: new google.maps.LatLng(-1.3327011, 114.5706969),
- zoom: 5
- });
- var infoWindow = new google.maps.InfoWindow;
- // Change this depending on the name of your PHP or XML file
- downloadUrl('dbexporttanah.php', function(data) {
- var xml = data.responseXML;
- var markers = xml.documentElement.getElementsByTagName('project');
- Array.prototype.forEach.call(markers, function(markerElem) {
- var Project = markerElem.getAttribute('Project');
- var Project2 = markerElem.getAttribute('Project2');
- var Scope = markerElem.getAttribute('Scope');
- var Area = markerElem.getAttribute('Area');
- var Position = markerElem.getAttribute('Position');
- var Company = markerElem.getAttribute('Company');
- var Years = markerElem.getAttribute('Years');
- var point = new google.maps.LatLng(
- parseFloat(markerElem.getAttribute('lat')),
- parseFloat(markerElem.getAttribute('long')));
- var infowincontent = document.createElement('div');
- var strong = document.createElement('strong');
- strong.textContent = Project
- infowincontent.appendChild(strong);
- infowincontent.appendChild(document.createElement('br'));
- var strong = document.createElement('strong');
- strong.textContent = Project2
- infowincontent.appendChild(strong);
- infowincontent.appendChild(document.createElement('br'));
- var text = document.createElement('text');
- text.textContent = Area
- infowincontent.appendChild(text);
- infowincontent.appendChild(document.createElement('br'));
- var marker = new google.maps.Marker({
- map: map,
- position: point
- });
- marker.addListener('click', function() {
- infoWindow.setContent(infowincontent);
- infoWindow.open(map, marker);
- });
- });
- });
- }
- function downloadUrl(url, callback) {
- var request = window.ActiveXObject ?
- new ActiveXObject('Microsoft.XMLHTTP') :
- new XMLHttpRequest;
- request.onreadystatechange = function() {
- if (request.readyState == 4) {
- request.onreadystatechange = doNothing;
- callback(request, request.status);
- }
- };
- request.open('GET', url, true);
- request.send(null);
- }
- function doNothing() {}
- </script>
Add Comment
Please, Sign In to add comment