function main_manage_maps() { $pdo = new PDO2(); $conn = $pdo->conn(); if (isset($_POST['endereco']) && isset($_POST['action']) == 'add') { $get = $_POST; $message = $pdo->insert($conn, $get); if ($message != '') { echo $message = "<h1>Inserido com sucesso</h1>"; } else { echo $message; } } else { if ($_GET['action'] == 'delete') { $pdo->delete($_GET['id'], $conn); echo "<h1>Deletado com sucesso</h1>"; } } echo "\n <h1>Cadastro de Endereços</h1>\n <form action='admin.php?page=manage-maps' method='post'>\n <div class='admin_manage_maps'>\n <table>\n <tr>\n <th>Cep</th>\n <th>Endereço</th>\n <th>Numero</th>\n </tr>\n <tr>\n <td><input type='text' value='' name='cep'/></td>\n <td><input type='text' value='' name='endereco'/></td>\n <td><input type='text' value='' name='numero' /></td>\n </tr>\n <tr>\n <th>Bairro</th>\n <th>Cidade</th>\n <th>Estado</th>\n </tr>\n <tr>\n <td><input type='text' value='' name='bairro' /></td>\n <td><input type='text' value='' name='cidade' /></td>\n <td><input type='text' value='' name='estado'/></td>\n </tr>\n <tr>\n <td><input type='submit' value='Cadastrar'/></td>\n <input type='hidden' name='action' value='add' />\n <input type='hidden' name='page' value='manage-maps' />\n </tr>\n </table>\n </div>\n </form>\n "; //show list data in base $object = $pdo->showlist($conn); ?> <table width='100%'> <tr> <th>Cep</th> <th>Endereço</th> <th>Número</th> <th>Bairro</th> <th>Cidade</th> <th>Estado</th> <th>Deletar</th> </tr> <?php while ($data = mysql_fetch_array($object)) { ?> <tr> <td class="row-title"><?php echo utf8_decode($data['cep']); ?> </td> <td class="row-title"><?php echo utf8_decode($data['endereco']); ?> </td> <td class="row-title"><?php echo utf8_decode($data['numero']); ?> </td> <td class="row-title"><?php echo utf8_decode($data['bairro']); ?> </td> <td class="row-title"><?php echo utf8_decode($data['cidade']); ?> </td> <td class="row-title"><?php echo utf8_decode($data['estado']); ?> </td> <td class="row-title"><a href='admin.php?page=manage-maps&action=delete&id=<?php echo utf8_decode($data['id']); ?> '>[X]</a></td> </tr> <?php } //endwhile echo "</table>"; }
function widget($args, $instance) { extract($args); /** This filter is documented in wp-includes/default-widgets.php */ $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); /* $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance ); echo $before_widget; if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } */ ?> <!-- <div class="textwidget"><?php /*echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; */ ?> </div> --><?php /* echo $after_widget;*/ include WP_PLUGIN_URL . '/manage-maps/PDO.php'; ?> <style> html, body { height: 100%; margin: 0px; padding: 0px } #map-canvas { height: 254px !important; width: 352px !important; } #panel { position: absolute; top: 5px; left: 50%; margin-left: -180px; z-index: 5; background-color: #fff; padding: 5px; border: 1px solid #999; } </style> <?php echo $title; ?> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css"> <script> var directionsDisplay; var directionsService = new google.maps.DirectionsService(); var map; function initialize() { directionsDisplay = new google.maps.DirectionsRenderer(); var chicago = new google.maps.LatLng(-23.6824124, -46.5952992); var mapOptions = { zoom: 6, center: chicago } map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); <?php $pdo = new PDO2(); $conn = $pdo->conn(); $object = $pdo->showlist($conn); while ($data = mysql_fetch_array($object)) { ?> jQuery.get( "http://maps.googleapis.com/maps/api/geocode/json", { address: "<?php echo utf8_decode($data['endereco']); ?> , <?php echo $data['numero']; ?> - <?php echo utf8_decode($data['bairro']); ?> - <?php echo utf8_decode($data['estado']); ?> " }, function(data){ console.log(data); var marker = new google.maps.Marker({ position: data.results[0].geometry.location, map: map, title: data.results[0].formatted_address }); google.maps.event.addListener(marker, 'click', function () { jQuery("#end").val(data.results[0].formatted_address); }); }); <?php } ?> directionsDisplay.setMap(map); } function calcRoute() { var start = document.getElementById('start').value; var end = document.getElementById('end').value; var waypts = []; var checkboxArray = document.getElementById('waypoints'); for (var i = 0; i < checkboxArray.length; i++) { if (checkboxArray.options[i].selected == true) { waypts.push({ location:checkboxArray[i].value, stopover:true}); } } var request = { origin: start, destination: end, waypoints: waypts, optimizeWaypoints: true, travelMode: google.maps.TravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); var route = response.routes[0]; var summaryPanel = document.getElementById('directions_panel'); summaryPanel.innerHTML = ''; // For each route, display summary information. jQuery('#end').css('color','#000') for (var i = 0; i < route.legs.length; i++) { var routeSegment = i + 1; summaryPanel.innerHTML += '<b>Route Segment: ' + routeSegment + '</b><br>'; summaryPanel.innerHTML += route.legs[i].start_address + ' to '; summaryPanel.innerHTML += route.legs[i].end_address + '<br>'; for(var x=0; x < route.legs[i].steps.length; x++) { summaryPanel.innerHTML += route.legs[i].steps[x].instructions +' '+ route.legs[i].steps[x].distance.text + '<br />' } summaryPanel.innerHTML += route.legs[i].distance.text + '<br><br>'; } } else { jQuery('#end').css('color','red')} }); } google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <div id="map-canvas"></div> <div id="control_panel" style="float:right;width:30%;text-align:left;padding-top:20px"> <div style="margin-left: -215px;border-width:2px;"> <b>Filial:</b> <select id="start" style="width: 100%;"> <option value="">Selecione...</option> <?php $pdo = new PDO2(); $conn = $pdo->conn(); $object = $pdo->showlist($conn); while ($data = mysql_fetch_array($object)) { echo '<option value="' . utf8_decode($data['endereco']) . ', ' . utf8_decode($data['numero']) . ' - ' . utf8_decode($data['bairro']) . ' - ' . utf8_decode($data['cidade']) . ' ">' . utf8_decode($data['endereco']) . ', ' . utf8_decode($data['numero']) . ' - ' . utf8_decode($data['bairro']) . ' - ' . utf8_decode($data['cidade']) . '</option>'; } ?> </select> <br> <!-- <b>Waypoints:</b> <br>--> <!-- <i>(Ctrl-Click for multiple selection)</i> <br>--> <select multiple id="waypoints" style="display: none; width: 100%;"> <option value="montreal, quebec">Montreal, QBC</option> <option value="toronto, ont">Toronto, ONT</option> <option value="chicago, il">Chicago</option> <option value="winnipeg, mb">Winnipeg</option> <option value="fargo, nd">Fargo</option> <option value="calgary, ab">Calgary</option> <option value="spokane, wa">Spokane</option> </select> <br> <b>End:</b> <!-- <select id="end"> <option value="R. Lucimar Fernandes Dantas - Jardim Santa Rosa, Ferraz de Vasconcelos - SP, República Federativa do Brasil">Rua Lucimar Fernandes Dantas</option> <option value="Seattle, WA">Seattle, WA</option> <option value="San Francisco, CA">San Francisco, CA</option> <option value="Los Angeles, CA">Los Angeles, CA</option> </select> --> <input type="text" name="end" id="end" value="" style="width: 100%; margin-bottom: 3px;"/> <br> <input type="submit" onclick="calcRoute();"> </div> <div id="directions_panel" style="margin-left:-215px;background-color:#FFEE77;"></div> </div> </body> <script type="text/javascript"> jQuery(function() { function carregarNoMapa(endereco) { jQuery.get( "http://maps.googleapis.com/maps/api/geocode/json", { address: endereco }, function(data){ console.log(data); } ); } $("#end").blur(function() { if($(this).val() != "") carregarNoMapa($(this).val()); }); // var availableTags = [ // "ActionScript", // "AppleScript", // "Asp", // "BASIC", // "C", // "C++", // "Clojure", // "COBOL", // "ColdFusion", // "Erlang", // "Fortran", // "Groovy", // "Haskell", // "Java", // "JavaScript", // "Lisp", // "Perl", // "PHP", // "Python", // "Ruby", // "Scala", // "Scheme" // ]; // jQuery( "#end" ).autocomplete({ // source: availableTags // }); }); </script> <?php }