- <!DOCTYPE html>
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="css/style.css">
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
- <script type="text/javascript"
- src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDX7Gqep0RvvG0Gb7ic1ZNcMtKvWZrJEMw&sensor=false"></script>
- <script src="clearbox/clearbox.js" type="text/javascript"></script>
- <script src="clearbox/clearbox.js?dir=scripts/clearbox&lng=eng" type="text/javascript"></script>
- <script type="text/javascript">
- var
- markers = [], // Masīvs ar marker'iem, kas ir uz kartes
- map;
- function initialize(){
- var styleArray = [
- {
- featureType : 'all',
- stylers : [
- { saturation : -255 }
- ]
- },
- {
- featureType : 'road.arterial',
- elementType : 'geometry',
- stylers : [
- { hue : '#606060' },
- { saturation : 0 }
- ]
- },
- {
- featureType : 'poi.business',
- elementType : 'labels',
- stylers : [
- { visibility : 'off' }
- ]
- }
- ];
- var myOptions = {
- panControl : false,
- zoomControl : true,
- mapTypeControl : false,
- scaleControl : false,
- streetViewControl : false,
- overviewMapControl : false,
- zoom : 15,
- mapTypeId : google.maps.MapTypeId.ROADMAP,
- styles : styleArray
- };
- var map = new google.maps.Map(document.getElementById("map_canvas"),
- myOptions);
- if(navigator.geolocation){
- navigator.geolocation.getCurrentPosition(function(position){
- var pos = new google.maps.LatLng(position.coords.latitude,
- position.coords.longitude);
- // MY TARGET LOCATION //
- var image = 'images/marker2.png';
- var whereami = new google.maps.Marker({
- position : pos,
- map : map,
- icon : image
- });
- map.setCenter(pos);
- }, function(){
- handleNoGeolocation(true);
- });
- }
- else{
- handleNoGeolocation(false);
- }
- // Šeit iegūstam punktus
- var
- points = [], // Tukšs masīvs
- str = '0';
- // Iegūstam datus caur ajax
- $.ajax({
- async : false, // NE-ASINHRONI! citādi kods izpildīsies talāk nesagaidot ajax atbildi!
- url : 'getcord.php',
- type : 'POST',
- dataType : 'json',
- data : { 'filter' : str},
- success : function(response){
- // Uzstādam iegūto response kā punktus
- points = response;
- }
- });
- // Debugošanai:
- console.log('Pēc ajax punkti:', points);
- // Uzliekam markerus
- setMarkers(map, points);
- }
- /**
- * Funkcija aizvāc visus markerus no kartes (izņemot lietotāja atrašanās markeri)
- */
- function clearAllMarkers(){
- // Aizvācam visus markerus
- for(var i = 0; i < markers.length; i++){
- markers[i].setMap(null);
- }
- // Notīram markeru masīvu - uzstādam kā tukšu masīvu
- markers = [];
- }
- function setMarkers(map, locations){
- var image = new google.maps.MarkerImage('images/marker.png',
- new google.maps.Size(40, 36),
- new google.maps.Point(0, 0),
- new google.maps.Point(-6, 52));
- var shadow = new google.maps.MarkerImage('images/marker_shadow.png',
- new google.maps.Size(40, 36),
- new google.maps.Point(0, 0),
- new google.maps.Point(0, 32));
- var shape = {
- coord : [1, 1, 1, 20, 18, 20, 18 , 1],
- type : 'poly'
- };
- console.log(locations.length);
- for(var i = 0; i < locations.length; i++){
- var beach = locations[i];
- var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
- var marker = new google.maps.Marker({
- position : myLatLng,
- map : map,
- shadow : shadow,
- icon : image,
- shape : shape,
- title : beach[0],
- animation : google.maps.Animation.DROP
- });
- // Pievienojam konkrēto markeri kopējam markeru masīvam
- markers.push(marker);
- }
- }
- function tests(){
- if(points){
- for(var i = 0; i < points.length; i++){
- points[i].setMap(null);
- }
- }
- }
- function openF(){
- google.maps.Map.prototype.clearOverlays = function(){
- console.log(beach);
- alert("aa");
- if(beach){
- for(var i = 0; i < beach.length; i++){
- beach[i].setMap(null);
- }
- }
- }
- }
- function showResult(str){
- if(str.length == 0){
- document.getElementById("livesearch").innerHTML = "";
- document.getElementById("livesearch").style.border = "0px";
- return;
- }
- if(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp = new XMLHttpRequest();
- }
- else{// code for IE6, IE5
- xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange = function(){
- if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
- document.getElementById("livesearch").innerHTML = xmlhttp.responseText;
- document.getElementById("livesearch").style.border = "1px solid #A5ACB2";
- }
- }
- xmlhttp.open("GET", "getprofesion.php?q=" + str, true);
- xmlhttp.send();
- }
- </script>
- <script src="js/jquery-1.7.2.js"></script>
- <script src="ui/jquery.effects.core.js"></script>
- <script src="ui/jquery.effects.fold.js"></script>
- <script>
- $(document).ready(function(){
- $("#show").click(function(){
- $(".filters_down").show("fold",
- {
- horizFirst : false,
- size : 28
- }, 2500);
- });
- $("#hide").click(function(){
- $(".filters_down").hide("fold",
- {
- horizFirst : false,
- size : 28
- }, 1500);
- });
- });
- </script>
- </head>
- <body onload="initialize()">
- <!-- header content -->
- <div class="header">
- <div id="logo"></div>
- <div class="top_menu">
- <!-- home icon -->
- <div id="home"></div>
- <ul>
- <li><a href="#" id="cur">Find a job near you</a></li>
- <li><a href="#">Seek for an emplyee </a></li>
- </ul>
- </div>
- <!-- end of top_menu-->
- <div class="support">
- <p id="supporters">
- <h3>Supporters</h3></p>
- <ul>
- <li><img src="images/Untitled-1_08.gif" alt="Untitled-1_08" width="" height=""/></li>
- <li><img src="images/Untitled-1_09.jpg" alt="Untitled-1_09" width="" height=""/></li>
- <li><img src="images/Untitled-1_10.jpg" alt="Untitled-1_10" width="" height=""/></li>
- </ul>
- </div>
- </div>
- <div class="filters">
- <a id="show"><h4 id="filter_title" id="show">Search a profession</h4>
- <img src="images/showhide.png" alt="show hide" width="" height=""/></a>
- </div>
- <div class="filters_down">
- <a id="hide"><img src="images/showhide.png" alt="show hide" width="" height=""/></a>
- <h4>What profession you'r interested in?</h4><br>
- <input type="text" id="squery" onchange="showResult(this.value)">
- <br>
- <br>
- <div id="livesearch"></div>
- </div>
- <div id="map_canvas"></div>
- </body>
- </html>