Advertisement
Guest User

wad

a guest
Nov 28th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4. <head>
  5.     <meta charset="utf-8" />
  6.     <meta name="format-detection" content="telephone=no" />
  7.     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
  8.     <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
  9.     <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  10.     <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
  11.     <script src="http://maps.google.com/maps/api/js?sensor=false&language=pl"></script>
  12.     <script src="gmap/gmap3.min.js"></script>
  13.     <title>Hello World</title>
  14.     <script>
  15.        
  16.         var kolory = "#000000";
  17.         var tab = []; // tablica z lokalizacjami
  18.         var imie;
  19.         var nazwy = [];
  20.         var bstreet = false;
  21.         var pzserw = false;
  22.         $(document).on("pageinit", "#startowa", function () {
  23.             $("#startbt").click(function () {
  24.                 imie = $("#username").val();
  25.                 window.location = "#calosc";
  26.             });
  27.         });
  28.  
  29.         $(document).on("pageinit", "#calosc", function () {
  30.            
  31.             var x, y, z;
  32.          
  33.             y = 0;
  34.             x = 0;
  35.             z = 5;
  36.             var idmark = 1;
  37.             var licz = 0;
  38.             $("#mark").on("click", ".centr", function () {
  39.                 var index = $(this).parents('li').index();
  40.                 $('#mapDiv').gmap3({
  41.                     map: {
  42.                         options: {
  43.                             center: [tab[index].szer, tab[index].dl],
  44.                             zoom: tab[index].prz,
  45.                             disableDefaultUI: true
  46.                         },
  47.                     },
  48.                     marker: {
  49.                         latLng: [tab[index].lat, tab[index].lng],
  50.                         id: [tab[index].id]
  51.                     }
  52.                 });
  53.  
  54.             });
  55.             $("#kasujWszystko").click(function () {
  56.                 $("#mapDiv").gmap3({
  57.                     clear: 'marker'
  58.                 });
  59.                 $("#mapDiv").gmap3({
  60.                     clear: 'polyline'
  61.                 });
  62.                 $("#mark *").remove();
  63.                 idmark = 1;
  64.             });
  65.             $("#obecnaPozycja").click(function () {
  66.                 var geoOptions = {
  67.                     maximumAge: 3000,
  68.                     timeout: 5000,
  69.                     enableHighAccuracy: true
  70.                 }
  71.                 function onGeoSuccess(position) {
  72.                     console.log("success");
  73.                     Longitude = position.coords.longitude;
  74.                     Latitude = position.coords.latitude;
  75.                     $("#mapDiv").gmap3({
  76.                         clear: 'getLocationMarker'
  77.                     })
  78.                     $('#mapDiv').gmap3({
  79.                         map: {
  80.                             options: {
  81.                                 center: [Latitude, Longitude],
  82.                                 zoom: 5,
  83.                             },
  84.                         },
  85.                         marker: {
  86.                             latLng: [Latitude, Longitude],
  87.                             id: 'getLocationMarker'
  88.                         }
  89.                     });
  90.                 }
  91.                 navigator.geolocation.getCurrentPosition(onGeoSuccess);
  92.             });
  93.             $("#quit").click(function () {
  94.                 navigator.app.exitApp();
  95.             });
  96.  
  97.             $("#popupek").on("click", ".kol", function () {
  98.                 var index = $(this).index();
  99.                 for (var i = 0; i <= 9; i++) {
  100.                     var qolr = $("#kol" + i);
  101.                     $(qolr).height("50px");
  102.                     $(qolr).width("50px");
  103.                    
  104.                     $(qolr).css("border", "");
  105.                 }
  106.                 $(this).height($(this).height() - 8);
  107.                 $(this).width($(this).width() - 8);
  108.                 this.style.border = "4px solid #FFFF00";
  109.                 // alert(index);
  110.                 index = parseInt(index);
  111.                 if (index == 0) {
  112.                     kolory = "#FF0000";
  113.                  
  114.                  
  115.                 }
  116.                 else if (index == 1)
  117.                 {
  118.                     kolory = "#000000";
  119.                  
  120.                 }
  121.                 else if (index == 2) {
  122.                     kolory = "#0000FF";
  123.                 }
  124.                 else if (index == 3) {
  125.                     kolory = "#FF7F50";
  126.                 }
  127.                 else if (index == 4) {
  128.                     kolory = "#006400";
  129.                 }
  130.                 else if (index == 5) {
  131.                     kolory = "#228B22";
  132.                 }
  133.                 else if (index == 6){
  134.                     kolory = "#FFFFF0";
  135.             }
  136.                 else if (index == 7) {
  137.                     kolory = "#BA55D3";
  138.                 }
  139.                 else if (index == 8) {
  140.                     kolory = "#FF4500";
  141.                 }
  142.             });
  143.  
  144.             $("#zapisz").click(function () {
  145.                 localStorage.setItem("markery", JSON.stringify(tab));
  146.             });
  147.             $("#wczytaj").click(function () {
  148.                 if (localStorage.getItem("markery") != null && localStorage.getItem("markery") != undefined) {
  149.                     tab = JSON.parse(localStorage.getItem("markery"));
  150.                     for (var i = 0; i < tab.length; i++) {
  151.                         $("#mark").append("<li><a class='centr'>Marker " + idmark + "</a><a class='del' data-icon='delete' id='" + tab[i].id + "'></a></li>");
  152.                         $("#mapDiv").gmap3({
  153.                             marker: {
  154.                                 options: {
  155.                                     draggable: false,
  156.                                 },
  157.                                 id: tab[i].id,
  158.                                 latLng: [tab[i].szer, tab[i].dl],
  159.                                 zoom: tab[i].prz
  160.                             }
  161.                         });
  162.                         idmark++;
  163.                     }
  164.                     $("#mark").listview('refresh');
  165.  
  166.                 }
  167.             });
  168.             function zmiana() {
  169.  
  170.                 x = $("#input1").val();
  171.                 y = $("#input2").val();
  172.                 z = $("#input3").val();
  173.                 $("#mapDiv").gmap3({
  174.                     map: {
  175.                         options: {
  176.                             center: [parseInt(x), parseInt(y)],
  177.                             zoom: parseInt(z)
  178.  
  179.  
  180.                         }
  181.                     }
  182.                 })
  183.             }
  184.  
  185.             $(".inp").change(function () { zmiana() });
  186.             $("#mapDiv").width("100%");
  187.             $("#mapDiv").height($(window).height());
  188.        
  189.             $("#streetDiv").width("100%");
  190.             setTimeout(function () {
  191.  
  192.                 $("#mapDiv").gmap3({
  193.                     map: {
  194.                         options: {
  195.                             center: [x, y],
  196.                             zoom: 5,
  197.                             disableDefaultUI: true,
  198.                             disableDoubleClickZoom: true
  199.  
  200.                         },
  201.                         events: {
  202.                             click: function (map, event) {
  203.                                 console.log("CLICK");
  204.                                 var x = event.latLng.lat();
  205.                                 var y = event.latLng.lng();
  206.                                 var z = map.getZoom();
  207.                                 if (bstreet == false) {
  208.                                     $("#mark").append("<li><a class='centr'>Marker " + idmark + "</a><a class='del' data-icon='delete' id='mark" + idmark + "'></a></li>");
  209.                                     $("#mark").listview('refresh');
  210.                                     $("#mapDiv").gmap3({
  211.                                         marker: {
  212.                                             options: {
  213.                                                 draggable: false,
  214.                                             },
  215.                                             id: "mark" + idmark,
  216.                                             latLng: [x, y],
  217.                                             zoom: parseInt(z)
  218.                                         }
  219.  
  220.                                     });
  221.                                     idmark += 1;
  222.  
  223.                                     tab.push({ szer: x, dl: y, prz: z, id: "mark" + idmark });     // dodanie pierwszego obiektu na początek tablicy
  224.                                     // alert(tab[licz].szer);
  225.                                     licz += 1;
  226.                                 }
  227.                                 else {
  228.                                     $("#mapDiv").gmap3({
  229.                                         streetviewpanorama: {                      
  230.                        
  231.                                             options: {
  232.                                                 container: $("#streetDiv"),
  233.                                                 opts: {                              
  234.                                                     position: [x, y],
  235.                                                     pov: {
  236.                                                         heading: 4,
  237.                                                         pitch: 5,
  238.                                                         zoom: 1
  239.                                                     }
  240.                                                 },
  241.  
  242.                                             }
  243.                                         }
  244.                                        
  245.  
  246.                                     });
  247.                                   }
  248.                                
  249.                             }
  250.                         }
  251.                     }
  252.                 });
  253.                 $("#mapDiv").css("overflow", "visible");
  254.             }, 500);
  255.         $("#checkbox1").change(function(){
  256.             if (bstreet == false) {
  257.                 bstreet = true;
  258.                 $("#mapDiv").height($(window).height() / 2);
  259.                 $("#streetDiv").height($(window).height() / 2);
  260.             }
  261.             else {
  262.                 bstreet = false;
  263.                 $("#mapDiv").height($(window).height());
  264.                 $("#streetDiv").height(0);
  265.             }
  266.         });
  267.             /*   $("#mapDiv").gmap3({
  268.                    map: {
  269.  
  270.                        events: {
  271.                            click: function (map, event) {
  272.                                console.log(event.latLng.lat());
  273.                                console.log(event.latLng.lng());
  274.                                console.log(map.getZoom());
  275.                                console.log(map.getCenter());
  276.                                 $("#input1").change(functio
  277.                                  $("#input2").change(functio
  278.                            }
  279.                        }
  280.                    }
  281.                })*/
  282.  
  283.             $("#mark").on("click", ".del", function () {
  284.                 var markers = $("#mapDiv").gmap3({
  285.                     get: {
  286.                         name: 'marker',
  287.                         all: true
  288.                     }
  289.                 });
  290.  
  291.                 var w = $(this).prop("id");
  292.                 var index = $(this).parents('li').index();
  293.                 tab.splice(index, 1);
  294.                 $("#mapDiv").gmap3({
  295.                     clear: {
  296.                         id: w
  297.                     }
  298.                 });
  299.                 $(this).parent().remove();
  300.  
  301.             });
  302.  
  303.             $("#rysujtrase").click(function () {
  304.                 var markerArray = [];
  305.                 //pobranie wszystkich markerow z mapy
  306.                 var markers = $("#mapDiv").gmap3({
  307.                     get: {
  308.                         name: 'marker',
  309.                         all: true
  310.                     }
  311.                 });
  312.  
  313.                 //dla kazdego markera do tablicy wrzucasz jego pozycje latLng
  314.                 for (var i = 0; i < markers.length; i++) {
  315.                     markerArray.push(markers[i].getPosition());
  316.                 }
  317.                 $("#mapDiv").gmap3({
  318.                     polyline: {
  319.                         options: {
  320.                             strokeColor: kolory,
  321.                             strokeOpacity: 0.8,
  322.                             strokeWeight: 2,
  323.                             path: markerArray
  324.                         }
  325.                     }
  326.                 })
  327.             });
  328.             ////////////////////////////////////////////////////////////////////
  329.  
  330.             $("#wyslij").click(function () {
  331.                 // loader
  332.                 ostatnia_data = new Date().toLocaleTimeString()
  333.  
  334.                 $.mobile.showPageLoadingMsg();
  335.  
  336.                 //upraszczam to co wysylam
  337.                 var sendTab = [];
  338.                 sendTab.push(imie);
  339.                 sendTab.push(ostatnia_data);
  340.                 sendTab.push(kolory);
  341.                 for (var i = 0; i < tab.length; i++) {
  342.                     sendTab.push([tab[i].szer, tab[i].dl, tab[i].prz]);
  343.                 }
  344.                 //alert(JSON.stringify(sendTab));
  345.                 var sendObj = {
  346.                     trasa: JSON.stringify(sendTab)
  347.                 }
  348.                 //jak wysylamy - AJAX
  349.                 $.ajax({
  350.                     type: "POST",
  351.                     url: "ZapisPliku.aspx",
  352.                     data: sendObj,
  353.                     dataType: "text",
  354.                     success: function (response) {
  355.                         $.mobile.hidePageLoadingMsg();
  356.                         alert(response);
  357.                     },
  358.                     error: function (xhr) {
  359.                         alert(xhr.responseText);
  360.                     }
  361.                 });
  362.             });
  363.  
  364.             $("#pobierz").click(function () {
  365.                 if (pzserw == false) {
  366.                     pzserw = true;
  367.                 var markerArray = [];
  368.                 trips = [];
  369.                
  370.                 function onSuccess(response) {
  371.                     allTripsOnServer = JSON.parse(response);
  372.  
  373.                     for (var i = 0; i < allTripsOnServer.length; i++) {
  374.                         trips.push(allTripsOnServer[i].slice(3, allTripsOnServer[i].length));
  375.                         nazwy.push(allTripsOnServer[i].slice(0, 3));
  376.                         $("#serw").append("<li ><a class='klikserwer'>" + nazwy[i] + "</a></li>");
  377.                         $("#serw").listview('refresh');
  378.                     }
  379.                     for (var i = 0; i < trips.length; i++) {
  380.                         markerArray.push([trips[i][0][0], trips[i][0][1]]);
  381.                     }
  382.                 }
  383.                 $.ajax({
  384.                     type: "POST",
  385.                     url: "ReadTrips.aspx",
  386.                     dataType: "text",
  387.                     success: onSuccess,
  388.                     error: function (xhr) {
  389.                         alert(xhr.responseText);
  390.                     }
  391.                 });
  392.  
  393.                 }
  394.             });
  395.  
  396.  
  397.             ////////////////////////////////////////////////////////////////////
  398.  
  399.  
  400.  
  401.             $(document).on("click", ".klikserwer", function () {
  402.                 $("#mapDiv").gmap3({
  403.                     clear: 'marker'
  404.                 });
  405.                 $("#mapDiv").gmap3({
  406.                     clear: 'polyline'
  407.                 });
  408.                 var _this = this;
  409.                 while ($(_this).prop("tagName") != "LI") {
  410.                     _this = $(_this).parent();
  411.                 }
  412.                 var indeks = $(_this).index();
  413.                 var color = nazwy[indeks][2];      
  414.                 $("#mapDiv").gmap3({
  415.                    
  416.                
  417.                     polyline: {
  418.                         options: {
  419.                             strokeColor: color,
  420.                             strokeOpacity: 0.5,
  421.                             strokeWeight: 4,
  422.                             path: trips[indeks]
  423.                         }
  424.                        
  425.                     },
  426.                     autofit: { }
  427.                 });
  428.                
  429.                 for (var i = 0; i < trips[indeks].length; i++) {
  430.                     $("#mapDiv").gmap3({
  431.                         marker: {
  432.                             options: {
  433.                                 draggable: false,
  434.                             },                        
  435.                             latLng: [trips[indeks][i][0], trips[indeks][i][1]],
  436.                             zoom: parseInt(trips[indeks][i][2])
  437.                         }
  438.  
  439.                     });
  440.                 }
  441.                
  442.             });
  443.  
  444.  
  445.  
  446.             ///////////////////////////////////////////////////////////////////////
  447.         });
  448.  
  449.  
  450.  
  451.  
  452.     </script>
  453.     <style>
  454.         #mapDiv {
  455.             width: 100%;
  456.         }
  457.         #h1 {
  458.             text-align: center;
  459.             margin: 0 auto;
  460.             float: left;
  461.         }
  462.  
  463.         .ui-content {
  464.             padding: 0px;
  465.         }
  466.  
  467.         #popupek {
  468.             width: 290px;
  469.             height: 300px;
  470.             margin: 0auto;
  471.         }
  472.  
  473.         #kol2 {
  474.             width: 50px;
  475.             height: 50px;
  476.             background: black;
  477.             margin: 20px;
  478.             float: left;
  479.         }
  480.  
  481.         #kol1 {
  482.             width: 50px;
  483.             height: 50px;
  484.             background: red;
  485.             margin: 20px;
  486.             float: left;
  487.         }
  488.  
  489.         #kol3 {
  490.             width: 50px;
  491.             height: 50px;
  492.             background: blue;
  493.             margin: 20px;
  494.             float: left;
  495.         }
  496.  
  497.         #kol4 {
  498.             width: 50px;
  499.             height: 50px;
  500.             background: #FF7F50;
  501.             margin: 20px;
  502.             float: left;
  503.         }
  504.  
  505.         #kol5 {
  506.             width: 50px;
  507.             height: 50px;
  508.             background: #006400;
  509.             margin: 20px;
  510.             float: left;
  511.         }
  512.  
  513.         #kol6 {
  514.             width: 50px;
  515.             height: 50px;
  516.             background: #228B22;
  517.             margin: 20px;
  518.             float: left;
  519.         }
  520.  
  521.         #kol7 {
  522.             width: 50px;
  523.             height: 50px;
  524.             background: #FFFFF0;
  525.             margin: 20px;
  526.             float: left;
  527.         }
  528.  
  529.         #kol8 {
  530.             width: 50px;
  531.             height: 50px;
  532.             background: #BA55D3;
  533.             margin: 20px;
  534.             float: left;
  535.         }
  536.  
  537.         #kol9 {
  538.             width: 50px;
  539.             height: 50px;
  540.             background: #FF4500;
  541.             margin: 20px;
  542.             float: left;
  543.         }
  544.  
  545.         #startowa img {
  546.             width: 25%;
  547.             margin-left: 37.5%;
  548.             margin-right: 37.5%;
  549.         }
  550.         .ww {
  551.             float:left;
  552.  
  553.         }
  554.         #pobierz {
  555.             position:absolute;
  556.             top:3px;
  557.             right:50px;
  558.  
  559.         }
  560.         #checkbox1 {
  561.         text-align:center;
  562.         }
  563.     </style>
  564. </head>
  565. <body>
  566.     <div id="startowa" data-role="page">
  567.         <img src="sitemap.png" />
  568.         <input type="text" value="Wpisz imie" id="username" />
  569.         <button id="startbt">Wyslij</button>
  570.     </div>
  571.  
  572.  
  573.     <div id="calosc" data-role="page">
  574.         <div data-role="header">
  575.             <h1>mapa GOOGLE</h1>
  576.             <a href="#mypanel" class="ww"><img src="lista.png" id="lista" /></a>
  577.             <a href="#popupek" data-rel="popup" class="ww"><img src="color.png" /></a>
  578.              <a href="#panel2"id="pobierz" class="ww"><img src="jd2.png" /></a>
  579.         </div>
  580.         <div data-role="content">
  581.             <div id="mapDiv">
  582.             </div>
  583.             <div id="streetDiv">
  584.             </div>
  585.  
  586.  
  587.         </div>
  588.         <div data-role="panel" id="mypanel">
  589.             <ul data-role="listview" id="mark"></ul>
  590.             <br />
  591.             <input type="range" id="input1" class="inp" value="0" min="-90" max="90" step="1" />
  592.             <input type="range" id="input2" class="inp" value="0" min="-180" max="180" step="1" />
  593.             <input type="range" id="input3" class="inp" value="5" min="1" max="15" step="1" />
  594.             <label> StreetView <input type="checkbox" name="checkbox" id="checkbox1"/></label>
  595.             <button id="rysujtrase">Rysuj trasę</button>
  596.             <button id="zapisz">Zapamiętaj dane</button>
  597.             <button id="wczytaj">Wczytaj dane</button>
  598.             <button id="wyslij">Wyślij na serwer</button>
  599.            
  600.             <button id="kasujWszystko">Kasuj wszystko</button>
  601.             <button id="obecnaPozycja">Obecna pozycja</button>
  602.             <button id="quit">Wyłącz aplikacje</button>
  603.         </div>
  604.  
  605.         <div data-role="panel" id="panel2">
  606.              <ul data-role="listview" id="serw"></ul>
  607.  
  608.         </div>
  609.  
  610.  
  611.         <div id="popupek" data-role="popup">
  612.             <div id="kol1" class="kol"></div>
  613.             <div id="kol2" class="kol"></div>
  614.             <div id="kol3" class="kol"></div>
  615.             <div id="kol4" class="kol"></div>
  616.             <div id="kol5" class="kol"></div>
  617.             <div id="kol6" class="kol"></div>
  618.             <div id="kol7" class="kol"></div>
  619.             <div id="kol8" class="kol"></div>
  620.             <div id="kol9" class="kol"></div>
  621.         </div>
  622.     </div>
  623.  
  624.  
  625.  
  626.  
  627.  
  628.     <!-- <script type="text/javascript" src="cordova.js"></script>-->
  629. </body>
  630. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement