Sandson 1 Denunciar post Postado Agosto 24, 2016 Estou com um erro de visualização de mapa na minha rádio online: Essa é a imagem original de como deve ficar: http://prnt.sc/c9nuqo Essa é a imagem de erro da minha rádio: http://prntscr.com/c9nyuj O arquivo que carrega o mapa é esse: <?php include('functions.php'); if($mapType == 'flags'){ include('markers.php'); } else { include 'map-chart.php'; } ?> <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title></title> <!--start javascripts--> <?php if($mapType == 'flags'){ ?> <script type="text/javascript" src="http://maps.google.com/maps/api/js?key=MINHAKEYAPIAQUI&sensor=false"></script> <script type="text/javascript" src="<?php echo $websiteUrl;?>js/util.js"></script> <script type="text/javascript" src="<?php echo $websiteUrl;?>js/infowindowcss.js"></script> <?php } else { echo '';} ?> <script src="//code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text/javascript" src="<?php echo $websiteUrl;?>js/jquery.tinyscrollbar.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#scrollbar').tinyscrollbar({ sizethumb: 100 }); var bodyHeight = parseInt(jQuery('body').height() + 20); $('#fancybox-wrap', window.parent.document).css('height', bodyHeight+'px').css('max-height', '90%' ); }); </script> <!--start css style--> <link rel="stylesheet" type="text/css" href="<?php echo $websiteUrl;?>css/cleanVertical.css" media="screen" /> </head> <body> <div id="listenersText"> <h1><?php echo $L_current_listeners;?>: <?php echo $currentListeners;?> </h1> <div id="listenersCountries"> <span><?php echo $L_listeners_per_country;?>:</span> <?php foreach ( $count_countries as $key => $val ) { echo $key.'(<i>'.$val.'</i>) | '; } ?> </div> <div id="map_canvas"></div> <div id="listnersList"><?php echo $L_listeners_list;?>:</div> <div id="scrollbar"> <div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div></div></div></div> <div class="viewport"> <div class="overview"> <div id="listenerInfo"> <?php foreach ( $mapData as $listener ) { $listener = explode( '|', $listener ); echo '<div class="item"><div class="city">'.$listener[2].' '.$listener[3].' </div>'.$L_listener_player.': '.$listener[6].'<div class="duration">'.$L_listener_duration.': '.$listener[4].'</div></div></li>'; } ?> </div> </div> </div> </div> </body> </html> Compartilhar este post Link para o post Compartilhar em outros sites
Sandson 1 Denunciar post Postado Agosto 24, 2016 O primeiro arquivo a ser puxado é esse: functions.php <?php include ( "settings.php" ); include ( "ip-files/geoip.inc" ); include ( "ip-files/geoipcity.inc" ); include ( "ip-files/geoipregionvars.php" ); $gi = geoip_open( "ip-files/GeoLiteCity.dat", GEOIP_STANDARD ); //time function function sec2hmsstats( $sec, $padHours = false ) { // holds formatted string $hms = ""; $hours = intval( intval( $sec ) / 3600 ); if ( $hours > 0 ) { $hms .= ( $padHours )?str_pad( $hours, 2, "0", STR_PAD_LEFT ).':':$hours.' hour(s) '; } $minutes = intval( ( $sec / 60 ) % 60 ); if ( $minutes > 0 ) { // then add to $hms (with a leading 0 if needed) $hms .= str_pad( $minutes, 2, " ", STR_PAD_LEFT ).' min. '; } // seconds are simple - just divide the total // seconds by 60 and keep the remainder $seconds = intval( $sec % 60 ); if ( $seconds > 0 ) { // add to $hms, again with a leading 0 if needed if ( $minutes > 0 ) { $hms .= '& '; } $hms .= str_pad( $seconds, 2, "0", STR_PAD_LEFT ).' sec.'; } // done! return $hms; } //**unwanted worlds function unWords($string,$banned_words) { foreach($banned_words as $banned_word) { if(stristr($string,$banned_word)){ return false; } } return true; } //countries group function function ArrayGroupByCount( $_array, $sort = false ) { $count_array = array(); $allcount = count( $_array ); foreach ( array_unique( $_array ) as $value ) { $count = 0; foreach ( $_array as $element ) { if ( $element == $value ) $count++; } $n_count = $count / $allcount; $count = round( $n_count * $allcount ); $count_array[$value] = $count; } if ( $sort == 'desc' ) arsort( $count_array ); elseif ( $sort == 'asc' ) asort( $count_array ); return $count_array; } //parse data from main shoutcast server $currentListeners = 0; $currentListenersadd = 0; $countries = array(); $shoutcastXML = 'cache/shoutcast.xml'; $shoutcastxml = simplexml_load_file( $shoutcastXML ); //** //start get values //** //current listeners $currentListeners += $shoutcastxml->CURRENTLISTENERS; //average time $averageTime = sec2hmsstats( $shoutcastxml->AVERAGETIME ); //station genre $stationGenre = $shoutcastxml->SERVERGENRE; //current song $currentSong = $shoutcastxml->SONGTITLE; //current artist $currentArtist = explode( ' - ', $currentSong ); $currentArtist = trim( $currentArtist[0] ); $currentArtistXML = urlencode( $currentArtist ); $currentArtistXML = utf8_encode( $currentArtistXML ); $currentSong = str_replace( $currentArtist, '', $currentSong ); $currentSong = str_replace( '-', '', $currentSong ); $currentSong = trim($currentSong); //**start get listeners**// foreach ( $shoutcastxml->LISTENERS->LISTENER as $listener ) { $record = geoip_record_by_addr( $gi, $listener->HOSTNAME ); //get city of this listener if(!empty($record->city)){ $city = utf8_encode($record->city); } //get state of this listener @$state = $GEOIP_REGION_NAME[$record->country_code][$record->region]; if(!empty($state)){ $state = $city.' '.$state.', '; } else {$state ='';} //get country of this listener if(!empty($record->country_name)){ $country = $record->country_name; } else {$country = '';} //get country flag of this listener if(!empty($record->country_code)){ $flag = $record->country_code; $flag = strtolower( $flag ); } else {$flag = '';} //listener player $listenerPlayer = urldecode($listener->USERAGENT); //make an array for listeners if(!empty($record->country_name)){ $countries[] = $record->country_name; } //get connect time of this listener $connect = sec2hmsstats( $listener->CONNECTTIME ); //Get latitude - longitude for listener's city if(!empty($record->latitude)){ $listenerLat = $record->latitude; } else {$listenerLat = '';} if(!empty($record->longitude)){ $listenerLon = $record->longitude; } else {$listenerLon = '';} //make map data array $mapData['MINHACHAVEAQUI'] = $listenerLat.'|'.$listenerLon.'|'.$state.'|'.$country.'|'.$connect.'|'.$flag.'|'.$listenerPlayer; } //** get additional servers listeners **// if( count($additionalServers) > 0){ $s = 1; foreach($additionalServers as $stream=>$pass){ $shoutcastXMLadd = 'cache/shoutcast_'.$s.'.xml'; $shoutcastxmladd = simplexml_load_file( $shoutcastXMLadd ); //total listeners per server $currentListenersadd += $shoutcastxmladd->CURRENTLISTENERS; foreach ( $shoutcastxmladd->LISTENERS->LISTENER as $listeneradd ) { $recordadd = geoip_record_by_addr( $gi, $listeneradd->HOSTNAME ); //get city of this listener if(!empty($recordadd->city)){ $cityadd = utf8_encode($recordadd->city); } else {$cityadd ='';} //get state of this listener @$stateadd = $GEOIP_REGION_NAME[$recordadd->country_code][$recordadd->region]; if(!empty($stateadd)){ $stateadd = $cityadd.' '.$stateadd.', '; } else {$stateadd ='';} //get country of this listener if(!empty($recordadd->country_name)){ $countryadd = $recordadd->country_name; } else {$countryadd ='';} //get country flag of this listener if(!empty($recordadd->country_code)){ $flagadd = $recordadd->country_code; $flagadd = strtolower( $flagadd ); } else {$flagadd ='';} //listener player if(!empty($listeneradd->USERAGENT)){ $listenerPlayeradd = urldecode($listeneradd->USERAGENT); } else {$listenerPlayeradd ='';} //make an array for listeners if(!empty($recordadd->country_name)){ $countries[] = $recordadd->country_name; } else {$countries[] ='';} //get connect time of this listener if(!empty($listeneradd->CONNECTTIME)){ $connectadd = sec2hmsstats( $listeneradd->CONNECTTIME ); } else {$connectadd ='';} //Get latitude - longitude for listener's city if(!empty($recordadd->latitude)){ $listenerLatadd = $recordadd->latitude; } else {$listenerLatadd ='';} if(!empty($recordadd->longitude)){ $listenerLonadd = $recordadd->longitude; } else {$listenerLonadd ='';} //make map data array $mapData[] = $listenerLatadd.'|'.$listenerLonadd.'|'.$stateadd.'|'.$countryadd.'|'.$connectadd.'|'.$flagadd.'|'.$listenerPlayeradd; } $s++; } } //get total listeners $currentListeners = $currentListeners + $currentListenersadd; $count_countries = ArrayGroupByCount( $countries, 'desc' ); //** get songs history **// foreach ( $shoutcastxml->SONGHISTORY->SONG as $songsHistory ) { //song title $songTitle = $songsHistory->TITLE; //song date played $songDate = round($songsHistory->PLAYEDAT); $songDate = date('j.n.Y @ G:i', $songDate); } ?> Compartilhar este post Link para o post Compartilhar em outros sites
Sandson 1 Denunciar post Postado Agosto 24, 2016 O SEGUNDO A SER PUXADO: <?php $markerdatastart = '<markers>'; $markerdata = ''; foreach ( $mapData as $marker ) { $marker = explode( '|', $marker ); $markerdata .= '<marker name="'.$marker[2].' '.$marker[3].'" player="'.$marker[6].'" duration="'.$marker[4].'" lat="'.$marker[0].'" lng="'.$marker[1].'" icon="images/flags/'.$marker[5].'.png"/> '; } $markerdataend = '</markers>'; $markersxml = "markers.xml"; $fh = fopen( $markersxml, 'w' ) or die( "can't open file" ); fwrite( $fh, $markerdatastart ); fwrite( $fh, $markerdata ); fwrite( $fh, $markerdataend ); fclose( $fh ); ?> Compartilhar este post Link para o post Compartilhar em outros sites
Sandson 1 Denunciar post Postado Agosto 24, 2016 E POR ÚLTIMO O MAP-CHART.PHP <?php $stats =''; foreach ( $count_countries as $key => $val ) { $stats .= "['".$key."',".$val."],"; } ?> <script type='text/javascript' src='https://www.google.com/jsapi'></script> <script type='text/javascript'> google.load('visualization', '1', {'packages': ['geochart']}); google.setOnLoadCallback(drawRegionsMap); function drawRegionsMap() { var data = google.visualization.arrayToDataTable([ ['Country', '<?php echo $L_listeners;?>'], <?php echo $stats;?> ]); var options = { minValue: 0, colors: ['#d2e9ff','#0076ec','#f4df68','#dabc10','#ff5959','#790000'], tooltip: { textStyle: { fontName: 'Arial, sans-serif', fontSize: 13 } } }; var chart = new google.visualization.GeoChart(document.getElementById('map_canvas')); chart.draw(data, options); }; </script> Compartilhar este post Link para o post Compartilhar em outros sites
Sandson 1 Denunciar post Postado Agosto 24, 2016 Sei que é muita coisa... Mas será que alguém poderia me ajudar com isso? Eu não sei nada....kkkkk sei muito pouco de php. Compartilhar este post Link para o post Compartilhar em outros sites
Sandson 1 Denunciar post Postado Agosto 24, 2016 Ah pessoal, ia esquecendo..... Se eu adicionar uma latitude e longitude ele carrega o mapa mas todo errado... a latitude e longitude é lá dos EUA e a bandeira do brasil fica lá... http://prntscr.com/c9o8wm $markerdatastart = '<markers>'; $markerdata = ''; foreach ( $mapData as $marker ) { $marker = explode( '|', $marker ); $markerdata .= '<marker name="'.$marker[2].' '.$marker[3].'" player="'.$marker[6].'" duration="'.$marker[4].'" lat="45.6818935'.$marker[0].'" lng="-84.6907399'.$marker[1].'" icon="images/flags/'.$marker[5].'.png"/> '; } que código eu posso colocar aí pra q ele vá automaticamente pro lugar certo? Compartilhar este post Link para o post Compartilhar em outros sites