﻿//<![CDATA[

    if (GBrowserIsCompatible()) {
      // this variable will collect the html which will eventualkly be placed in the side_bar
      var side_bar_html = "";
    
      // arrays to hold copies of the markers used by the side_bar
      // because the function closure trick doesnt work there
      var gmarkers = [];
      var i = 0;
          
		  var myIcon = new GIcon(G_DEFAULT_ICON);

		  var markerOptions = { icon:myIcon };
		  
      // A function to create the marker and set up the event window
      function createMarker(point,name,html) {
        var marker = new GMarker(point, markerOptions);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        // save the info we need to use later for the side_bar
        gmarkers[i] = marker;
        // add a line to the side_bar html

        i++;
        return marker;
      }


      // This function picks up the click and opens the corresponding info window
      function magaza(i) {
        GEvent.trigger(gmarkers[i], "click");
      }


      // create the map
      var map = new GMap2(document.getElementById("map"));
      //map.addControl(new YSliderControl());
      map.addControl(new GSmallMapControl);
      //map.addControl(new copy());
      //map.addControl(new GHierarchicalMapTypeControl);
      map.setMapType(G_HYBRID_MAP);
      map.addControl(new GOverviewMapControl);
      map.enableScrollWheelZoom();      
      map.setCenter(new GLatLng(40.18464,26.15020), 12);

   var polyline = new GPolyline([
  		  new GLatLng(40.10321, 26.32050),
  		  new GLatLng(40.10345, 26.31871),
  		  new GLatLng(40.10428, 26.31654),
  		  new GLatLng(40.10561, 26.31493),
  		  new GLatLng(40.10717, 26.31430),
  		  new GLatLng(40.10757, 26.31295),
  		  new GLatLng(40.10753, 26.31180),
  		  new GLatLng(40.10827, 26.31094),
  		  new GLatLng(40.10965, 26.31137),
  		  new GLatLng(40.10930, 26.30985),
  		  new GLatLng(40.10999, 26.30856),
  		  new GLatLng(40.11119, 26.30744),
  		  new GLatLng(40.11211, 26.30571),
  		  new GLatLng(40.11398, 26.30616),
  		  new GLatLng(40.11562, 26.30358),
  		  new GLatLng(40.11759, 26.30135),
  		  new GLatLng(40.12038, 26.30371),
  		  new GLatLng(40.12245, 26.29933),
  		  new GLatLng(40.12320, 26.29633),
  		  new GLatLng(40.12488, 26.29560),
  		  new GLatLng(40.12389, 26.29405),
  		  new GLatLng(40.12235, 26.29161),
  		  new GLatLng(40.12018, 26.29384),
  		  new GLatLng(40.11959, 26.29624),
  		  new GLatLng(40.11743, 26.29839),
  		  new GLatLng(40.11661, 26.30036),
  		  new GLatLng(40.11441, 26.30139),
  		  new GLatLng(40.11283, 26.30028),
  		  new GLatLng(40.11309, 26.30272),
  		  new GLatLng(40.11145, 26.30367),
  		  new GLatLng(40.10958, 26.30247),
  		  new GLatLng(40.10981, 26.30435),
  		  new GLatLng(40.10853, 26.30599),
  		  new GLatLng(40.10669, 26.30646),
  		  new GLatLng(40.10627, 26.30830),
  		  new GLatLng(40.10446, 26.30985),
  		  new GLatLng(40.10351, 26.30852),
  		  new GLatLng(40.10243, 26.31011),
  		  new GLatLng(40.10506, 26.31395),
  		  new GLatLng(40.10374, 26.31573),
  		  new GLatLng(40.10308, 26.31882),
  		  new GLatLng(40.10301, 26.31930),
  		  new GLatLng(40.10308, 26.32035)
  		 		], "#ff0000", 10);

        /* //replacement code
       var polyline = new GPolyline([], "#ff0000", 10);
       polyline.insertVertex(0, new GLatLng(37.4419, -122.1419));
       polyline.insertVertex(1, new GLatLng(37.4519, -122.1519));*/
		
		map.addOverlay(polyline);


      // Read the data from example.xml
      var request = GXmlHttp.create();
      request.open("GET", "pozisyon.xml", true);
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          var xmlDoc = GXml.parse(request.responseText);
          // obtain the array of markers and loop through it
          var markers = xmlDoc.documentElement.getElementsByTagName("marker");
        
  
		  
          for (var i = 0; i < markers.length; i++) {
            // obtain the attribues of each marker
            var lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
            var point = new GLatLng(lat,lng);
            var html = markers[i].getAttribute("html");
            var label = markers[i].getAttribute("label");
            // create the marker
            var marker = createMarker(point,label,html);
            map.addOverlay(marker);
          }
          // put the assembled side_bar_html contents into the side_bar div
          //document.getElementById("side_bar").innerHTML = side_bar_html;
        }
      }
      request.send(null);
    }

    else {
      alert("Browser Hatası");
    }


    //]]>
