if('undefined' != typeof $( ".addresspicker_map" ).html() ){

    var lat=$("#lat").val()?$("#lat").val():24.694970,
    lng=$("#lng").val()?$("#lng").val():46.724130
    var addresspickerMap = $( ".addresspicker_map" ).addresspicker({
        regionBias: "en",
        language: "ar",
        updateCallback: showCallback,
        reverseGeocode:true,//set to false to disable call google ajax and avoid OVER_QUERY_LIMIT
        mapOptions: {
          zoom: 12,
          center: new google.maps.LatLng(lat,lng),
          scrollwheel: false,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        },
        elements: {
          map:      "#map",
          lat:      "#lat",
          lng:      "#lng",
        }
      });

    var gmarker = addresspickerMap.addresspicker( "marker");
    // alert(typeof gmarker)
    if('undefined' != typeof gmarker ){
        gmarker.setVisible(true);
    }
    function showCallback(geocodeResult, parsedGeocodeResult){
        console.log(parsedGeocodeResult)
        console.log(JSON.stringify(parsedGeocodeResult, null, 4))
        areaName = parsedGeocodeResult['locality'] ? parsedGeocodeResult['locality'] : parsedGeocodeResult['administrative_area_level_1']
        cityName = parsedGeocodeResult['sublocality'] ? parsedGeocodeResult['sublocality'] : parsedGeocodeResult['administrative_area_level_2']
        cityName = cityName ? cityName : areaName

        if($('.areaName')){
            $('.areaName').val( areaName )
        }
        if($('.cityName')){
            $('.cityName').val( cityName )
        }
        // alert('location address '+JSON.stringify(parsedGeocodeResult, null, 4));
    }
}