﻿
var MainMap=null;
var markersArray = [];

function ShowMap(obj,latitude,longitud) {
    //alert('asdasd23');
    //var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
    //initialLocation = newyork;
    var initialLocation = new google.maps.LatLng(latitude, longitud); ;
    
    
    var browserSupportFlag = new Boolean();
    var map;
    var infowindow = new google.maps.InfoWindow();

    
    
        var myOptions = {
            zoom: 15,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
        map.setCenter(initialLocation);

        MainMap = map;



        var imageCliente = new google.maps.MarkerImage('/Files/_E1/_G70/_P70/Imagenes/Iconos/UD.png',
                new google.maps.Size(30, 30),
                new google.maps.Point(0, 0),
                new google.maps.Point(15, 15));
        var markerCliente = new google.maps.Marker({
            position: initialLocation,
            map: MainMap,
            icon: imageCliente,
            title: 'UD.',
            zIndex: 100
        });
        markersArray.push(markerCliente);



        //contentString = "H!";
        //infowindow.setContent(contentString);
        //infowindow.setPosition(initialLocation);
        //infowindow.open(map);


    }

////    //Ubicacion= ['Bondi Beach', -33.890542, 151.274856, 4]
////    function ShowMarker(Latitud,Longitud,Titulo,zindex) {
////        alert('holaXX'+Latitud+':'+Longitud+':'+Titulo+':'+zindex);

//////        var myOptions = {
//////            zoom: 5,
//////            mapTypeId: google.maps.MapTypeId.ROADMAP
//////        };
////        //        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);


//////        var image = new google.maps.MarkerImage('/Files/_E1/_G70/_P70/Imagenes/Iconos/Taxi.gif',
//////        // This marker is 20 pixels wide by 32 pixels tall.
//////        new google.maps.Size(20, 10),
//////        // The origin for this image is 0,0.
//////        new google.maps.Point(0, 0),
//////        // The anchor for this image is the base of the flagpole at 0,32.
//////        new google.maps.Point(10, 10));


//////        //var Location = Ubicacion;
//////            var myLatLng = new google.maps.LatLng(Latitud, Longitud);
//////            var marker = new google.maps.Marker({
//////                position: myLatLng,
//////                map: map,
//////                //shadow: shadow,
//////                icon: image,
//////                //shape: shape,
//////                title: Titulo,
//////                zIndex: zindex 
//////            });





////        var myLatlng = new google.maps.LatLng(-25.363882, 131.044922);
////        var myOptions = {
////            zoom: 4,
////            //center: myLatlng,
////            mapTypeId: google.maps.MapTypeId.ROADMAP
////        }
////        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

////        var image = 'http://code.google.com/intl/ca/apis/maps/documentation/v3/examples/images/beachflag.png';
////        var myLatLng = new google.maps.LatLng(-33.890542, 151.274856);
////        var beachMarker = new google.maps.Marker({
////            position: myLatLng,
////            map: map,
////            icon: image
////        });

////      


////    }




    //Ubicacion= ['Bondi Beach', -33.890542, 151.274856, 4]
    function ShowMarker(locations, ClienteLatitud, ClienteLongitud) {
        //alert('holaXX' + locations);

//        var myOptions = {
//            zoom: 10,
//            center: new google.maps.LatLng(ClienteLatitud, ClienteLongitud),
//            mapTypeId: google.maps.MapTypeId.ROADMAP
//        }
//        var map = new google.maps.Map(document.getElementById("map_canvas"),
//                                myOptions);


        clearOverlays();

        if (MainMap != null) {
           // alert('cargadoo');
            var image = new google.maps.MarkerImage('/Files/_E1/_G70/_P70/Imagenes/Iconos/Taxi.png',
            //var image = new google.maps.MarkerImage('http://code.google.com/intl/ca/apis/maps/documentation/v3/examples/images/beachflag.png',
            // This marker is 20 pixels wide by 32 pixels tall.
                new google.maps.Size(20, 20),
            // The origin for this image is 0,0.
                new google.maps.Point(0, 0),
            // The anchor for this image is the base of the flagpole at 0,32.
                new google.maps.Point(10, 10));

            for (var i = 0; i < locations.length; i++) {
                var beach = locations[i];
                var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
                //var myLatLng = new google.maps.LatLng(41.287, 2.053);
                var marker = new google.maps.Marker({
                    position: myLatLng,
                    //map: map,
                    map: MainMap,
                    //shadow: shadow,
                    icon: image,
                    //shape: shape,
                    title: beach[0],
                    zIndex: beach[3]
                });

                markersArray.push(marker);

            }


            var imageCliente = new google.maps.MarkerImage('/Files/_E1/_G70/_P70/Imagenes/Iconos/UD.png',
                new google.maps.Size(30, 30),
                new google.maps.Point(0, 0),
                new google.maps.Point(15, 15));
            var markerCliente = new google.maps.Marker({
                position: new google.maps.LatLng(ClienteLatitud, ClienteLongitud),
                map: MainMap,
                icon: imageCliente,
                title: 'UD.',
                zIndex: 100
            });
            markersArray.push(markerCliente);




        }





    }



    // Removes the overlays from the map, but keeps them in the array
    function clearOverlays(ClienteLatitud, ClienteLongitud) {
        if (markersArray) {
            for (i in markersArray) {
                markersArray[i].setMap(null);
            }

            //alert(ClienteLatitud+':'+ClienteLongitud);
            var imageCliente = new google.maps.MarkerImage('/Files/_E1/_G70/_P70/Imagenes/Iconos/UD.png',
                new google.maps.Size(30, 30),
                new google.maps.Point(0, 0),
                new google.maps.Point(15, 15));
            var markerCliente = new google.maps.Marker({
                position: new google.maps.LatLng(ClienteLatitud, ClienteLongitud),
                map: MainMap,
                icon: imageCliente,
                title: 'UD.',
                zIndex: 100
            });
            markersArray.push(markerCliente);
 
            
        }
        
        
    }

















