dannybarh's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Active Members
Active Posts:
65 (0.05 per day)
Joined:
19-February 11
Profile Views:
2,483
Last Active:
User is offline Sep 11 2014 06:00 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   dannybarh has not set their status

Posts I've Made

  1. In Topic: Update marker position every x second on google map without page load

    Posted 10 Sep 2014

    Hi, i have fixed it and it loads all the markers from db on my local pc, but when i upload the same code to the online server, it shops working. Am really at a lost here.

    i have been able to deploy google map on localhost, it loads all coordinates with success.
    But when i upload the same code to my server, it completely fails to load.I tried all i could, am really at a lost here.
    
        <html>
        <head>
    
        <script type='text/javascript' src='jquery-1.6.2.min.js'></script>
        <script type='text/javascript' src='jquery-ui-1.8.14.custom.min.js'></script>
    
        <style>
     
            BODY {font-family : Verdana,Arial,Helvetica,sans-serif; color: #000000; font-size : 13px ; }
     
            #map_canvas { width:100%; height: 100%; z-index: 0; }
        </style>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false" /></script>
       
        <script type='text/javascript'>
        jQuery(document).ready( function($){
                function closeInfos(){
                    if(infos.length > 0){
                        infos[0].set("marker",null);
                        infos[0].close();
                        infos.length = 0;
                    }
                }
        
            //Get data, and replace it on the form
            var geocoder;
            var map;
            var markersArray = [];
            var infos = [];
    
            geocoder = new google.maps.Geocoder();
            var myOptions = {
                  zoom: 9,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
                }
            var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);    
            
            function deleteMarkers() {
              for (var i = 0; i < markersArray.length; i++) {
                markersArray[i].setMap(null);
              }
    
              markersArray = [];
            }
    
        setInterval(function(){
            $.get('ajax_gp_gps.php', function(data){        
             var bounds = new google.maps.LatLngBounds();
            var encodedString;
            var stringArray = [];
            encodedString = data;
            stringArray = encodedString.split("****");
            
            var x;
            for (x = 0; x < stringArray.length; x = x + 1)
            {
                var addressDetails = [];
                var marker;
                addressDetails = stringArray[x].split("&&&");
                
                var lat = new google.maps.LatLng(addressDetails[1], addressDetails[2]);
                //alert(image + " " + addressDetails[1] );
                marker = new google.maps.Marker({ 
                    map: map, 
                    position: lat,
                    content: addressDetails[0]
                });
                markersArray.push(marker);
                google.maps.event.addListener( marker, 'click', function () {
                    closeInfos();
                    var info = new google.maps.InfoWindow({content: this.content});
                    // where I have added .html to the marker object.
                    //infowindow.setContent( marker.html);
                    info.open(map,this);
                    infos[0]=info;
                });
                bounds.extend(lat);
            }
    
            map.fitBounds(bounds);
    
               
            });
        },1000);
        
        });     
      </script>
    
    </head>
    <body>
     <?php include_once("ajax_gp_gps.php"); ?>
    <div id='input'>
            <input type="hidden" id="encodedString" name="encodedString" value="<?php echo $encodedString; ?>">
        </div>
        <div id="map_canvas"></div>
        
        </body>
    </html>
    
  2. In Topic: Update marker position every x second on google map without page load

    Posted 8 Sep 2014

    Thank you for for time.

    I added this script to the map Javascript so that i can load the markers from dbase every x second without refreshing the page...
    But the map is not showing at all, and its definitely not loading from dbase.

    //Ajax call to get gps coordinates
    
                  function set_center() {
    
                        var feedback = $.ajax({
    
                            type: 'GET',
    
                            url: 'ajax_refresh_gps.php',
    
                          success: function (data) {
    
                            console.log(data);
    
     
    
                //Load the lat, long data
    
                                var lat = new google.maps.LatLng(addressDetails[1], addressDetails[2]);
    
     
    
                                //Create a new marker and info window
    
                                marker = new google.maps.Marker({
    
                                    map: map,
    
                                    position: lat,
    
                                    //Content is what will show up in the info window
    
                                    content: addressDetails[0]
    
                                });
    
                        },
    
                    });
    
                  }
    
     
    
                  setInterval(set_center, 10000);
    
            //End ajax call to get gps coordinates
    
    
  3. In Topic: GPS script on server not receiving gps data

    Posted 3 Aug 2014

    it is not working, it has disable on my my share host server. I will give this try and get back. Am using this script to receive data from a gps tracker. I you know any script that can work , i will be grateful, thanks.

    <?php
    error_reporting(E_ALL);
    
    /* Permitir al script esperar para conexiones. */
    set_time_limit(0);
    
    /* Activar el volcado de salida implícito, así veremos lo que estamo obteniendo
    * mientras llega. */
    ob_implicit_flush();
    
    $address = 'xxx.xxx.xxx.xx';
    $port = 443;
    
    if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
        echo "socket_create() falló: razón: " . socket_strerror(socket_last_error()) . "\n";
    }
    
    if (socket_bind($sock, $address, $port) === false) {
        echo "socket_bind() falló: razón: " . socket_strerror(socket_last_error($sock)) . "\n";
    }
    
    if (socket_listen($sock, 5) === false) {
        echo "socket_listen() falló: razón: " . socket_strerror(socket_last_error($sock)) . "\n";
    }
    
    //clients array
    $clients = array();
    
    do {
        $read = array();
        $read[] = $sock;
        
        $read = array_merge($read,$clients);
        
        // Set up a blocking call to socket_select
        if(socket_select($read,$write = NULL, $except = NULL, $tv_sec = 5) < 1)
        {
            //    SocketServer::debug("Problem blocking socket_select?");
            continue;
        }
        
        // Handle new Connections
        if (in_array($sock, $read)) {        
            
            if (($msgsock = socket_accept($sock)) === false) {
                echo "socket_accept() falló: razón: " . socket_strerror(socket_last_error($sock)) . "\n";
                break;
            }
            $clients[] = $msgsock;
            $key = array_keys($clients, $msgsock);
            /* Enviar instrucciones. */
            $msg = "\nBienvenido al Servidor De Prueba de PHP. \n" .
            "Usted es el cliente numero: {$key[0]}\n" .
            "Para salir, escriba 'quit'. Para cerrar el servidor escriba 'shutdown'.\n";
            socket_write($msgsock, $msg, strlen($msg));
            
        }
        
        // Handle Input
        foreach ($clients as $key => $client) { // for each client        
            if (in_array($client, $read)) {
                if (false === ($buf = socket_read($client, 2048, PHP_NORMAL_READ))) {
                    echo "socket_read() falló: razón: " . socket_strerror(socket_last_error($client)) . "\n";
                    break 2;
                }
                if (!$buf = trim($buf)) {
                    continue;
                }
                if ($buf == 'quit') {
                    unset($clients[$key]);
                    socket_close($client);
                    break;
                }
                if ($buf == 'shutdown') {
                    socket_close($client);
                    break 2;
                }
                $talkback = "Cliente {$key}: Usted dijo '$buf'.\n";
                socket_write($client, $talkback, strlen($talkback));
    
                // write received gprs data to the file
    			writeToFile('gprs.log', $buf);
                //echo "$buf\n";
            }
            
        }        
    } while (true);
    
    socket_close($sock);
    
    ?> 
    
  4. In Topic: GPS script on server not receiving gps data

    Posted 3 Aug 2014

    Is there another function for creating php sockets apart from this
    socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    
    ?

    Really need to know, thanks.
  5. In Topic: GPS script on server not receiving gps data

    Posted 2 Aug 2014

    lol, 33 views is enough for some one to say hi at lest.

    am getting this error
    Fatal error: Call to undefined function socket_create() in /home/www/domain.com/gps_listener.php on line 14
    

    I need to enable in php.ini
    extension=php_sockets.dll
    
    to solve the issue. My script is online, so how do i enable it online?

    Here is my revised code

    <?php
    error_reporting(E_ALL);
    
    /* Permitir al script esperar para conexiones. */
    set_time_limit(0);
    
    /* Activar el volcado de salida implícito, así veremos lo que estamo obteniendo
    * mientras llega. */
    ob_implicit_flush();
    
    $address = 'xxx.xxx.xxx.xx';
    $port = 80;
    
    if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
        echo "socket_create() falló: razón: " . socket_strerror(socket_last_error()) . "\n";
    }
    
    if (socket_bind($sock, $address, $port) === false) {
        echo "socket_bind() falló: razón: " . socket_strerror(socket_last_error($sock)) . "\n";
    }
    
    if (socket_listen($sock, 5) === false) {
        echo "socket_listen() falló: razón: " . socket_strerror(socket_last_error($sock)) . "\n";
    }
    
    //clients array
    $clients = array();
    
    do {
        $read = array();
        $read[] = $sock;
    
        $read = array_merge($read,$clients);
    
        // Set up a blocking call to socket_select
        if(socket_select($read,$write = NULL, $except = NULL, $tv_sec = 5) < 1)
        {
            //    SocketServer::debug("Problem blocking socket_select?");
            continue;
        }
    
        // Handle new Connections
        if (in_array($sock, $read)) {        
    
            if (($msgsock = socket_accept($sock)) === false) {
                echo "socket_accept() falló: razón: " . socket_strerror(socket_last_error($sock)) . "\n";
                break;
            }
            $clients[] = $msgsock;
            $key = array_keys($clients, $msgsock);
            /* Enviar instrucciones. */
            $msg = "\nBienvenido al Servidor De Prueba de PHP. \n" .
            "Usted es el cliente numero: {$key[0]}\n" .
            "Para salir, escriba 'quit'. Para cerrar el servidor escriba 'shutdown'.\n";
            socket_write($msgsock, $msg, strlen($msg));
    
        }
    
        // Handle Input
        foreach ($clients as $key => $client) { // for each client        
            if (in_array($client, $read)) {
                if (false === ($buf = socket_read($client, 2048, PHP_NORMAL_READ))) {
                    echo "socket_read() falló: razón: " . socket_strerror(socket_last_error($client)) . "\n";
                    break 2;
                }
                if (!$buf = trim($buf)) {
                    continue;
                }
                if ($buf == 'quit') {
                    unset($clients[$key]);
                    socket_close($client);
                    break;
                }
                if ($buf == 'shutdown') {
                    socket_close($client);
                    break 2;
                }
                $talkback = "Cliente {$key}: Usted dijo '$buf'.\n";
                socket_write($client, $talkback, strlen($talkback));
    
                // write received gprs data to the file
                writeToFile('gprs.txt', $buf);
                //echo "$buf\n";
            }
    
        }        
    } while (true);
    
    socket_close($sock);
    
    ?> 
    

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

dannybarh has no profile comments yet. Why not say hello?