var hosturl = $("#hosturl").val();
var lat;
$(function () {
    function a(a, e, t, n) {
        var o = new MarkerWithLabel({
            position: a,
            map: e,
            icon: " ",
            labelContent: n,
            labelAnchor: new google.maps.Point(22, 22),
            labelClass: "labels",
            labelStyle: {opacity: 1},
            draggable: !1, animation: google.maps.Animation.DROP
        });
        return o.addListener("click", function () {
            $.post(l + "/search_map/mapsearch", {id: t}, function (a) {
                var n = jQuery.parseJSON(a);
                $("#branch_no").html(a.number),
                        new google.maps.InfoWindow({
                            content: '<div class="map-property">\n\
                                <h6 class="property-title col-md-12"><a class="title-link" href="' + l + "/property-details/" + t + '">' + n.title + '</a></h6>\n\
                                <a class="property-featured-image col-md-7" href="#" style:margin:0;><img class="property-thumb" src="' + l + "/upload/adv/" + n.image + '" alt="" style="height:100px ;width:111px"/></a>\n\
                                <p><br><span class="price" style="padding:10px;padding-top: 5px;">' + n.price + '  ر.س</span></p>\n\
                                <p><span class="price" style="padding:10px;padding-top: 5px;">' + n.area + "  متر مربع</span></p></div>"
                        }).open(e, o)
            })
        }), o
    }
    function e(a, e) {
        return new MarkerWithLabel({
            position: a,
            map: e,
            icon: " ",
            labelContent: price,
            labelAnchor: new google.maps.Point(22, 22),
            labelClass: "labels",
            labelStyle: {opacity: 1},
            draggable: !1,
            animation: google.maps.Animation.DROP
        })
    }
    var l = $("#hosturl").val();
    $("#lang").val();
    /*$("#rgn").on("change",function(){
     var n=$(this).val(),
     o=$("#lat").val(),
     p=$("#long").val(),
     g=new google.maps.LatLng(o,p);
     t=new google.maps.Map(document.getElementById("gmap"),{center:g,zoom:11,mapTypeId:google.maps.MapTypeId.ROADMAP});
     new MarkerWithLabel({
     position:g,
     map:t,
     labelContent:"K",
     labelAnchor:new google.maps.Point(22,22),
     labelClass:"labels",
     labelStyle:{opacity:.75},
     title:"Set lat/lon values for this property",
     draggable:!0
     });
     $.post(l+"/search_map/citymap",{ths_val:n},function(a){
     a=JSON.parse(a);
     var l,n=Number(a.length)-1;
     for(l=0;l<=n;l++){
     var o=a[l].lat,
     p=a[l].long,
     g=new google.maps.LatLng(o,p);
     t=new google.maps.Map(document.getElementById("gmap"),{center:g,zoom:9,mapTypeId:google.maps.MapTypeId.ROADMAP}),
     e(new google.maps.LatLng(a[l].lat,a[l].long),t)
     }
     }),
     $.post(l+"/search_map/mymap",{ths_val:n},function(e){
     e=JSON.parse(e);
     var l,
     n=Number(e.length)-1;
     for(l=0;l<=n;l++)a(new google.maps.LatLng(e[l].lat,e[l].lan),t,e[l].id,e[l].price)
     })
     });*/

    $('.getLocation').on('change', function () {
        var a = $("#lat").val(),
                e = $("#long").val(),
                l = new google.maps.LatLng(a, e);
        if ($("#gmap").length > 0)
        {
            t = new google.maps.Map(document.getElementById("gmap"), {center: l, zoom: 16, mapTypeId: google.maps.MapTypeId.ROADMAP});
            var n = new MarkerWithLabel({position: l, map: t, title: "Set lat/lon values for this property", draggable: !0});
            google.maps.event.addListener(n, "dragend", function (a) {
                document.getElementById("lat").value = a.latLng.lat().toFixed(4),
                        document.getElementById("long").value = a.latLng.lng().toFixed(4)
            })
        }
    });

    window.onload = function () {
        var a = $("#lat").val(),
                e = $("#long").val(),
                l = new google.maps.LatLng(a, e);
        if ($("#gmap").length > 0)
        {
            t = new google.maps.Map(document.getElementById("gmap"), {center: l, zoom: 16, mapTypeId: google.maps.MapTypeId.ROADMAP});
            var n = new MarkerWithLabel({position: l, map: t, title: "Set lat/lon values for this property", draggable: !0});
            google.maps.event.addListener(n, "dragend", function (a) {
                document.getElementById("lat").value = a.latLng.lat().toFixed(4),
                        document.getElementById("long").value = a.latLng.lng().toFixed(4)
            })
        }
    };




    var t
});