Wednesday, December 18, 2013

Passing null value to Integer in MVC

  int Password_No=0;

                    int chkpwdcnt = context.tbl_PasswordHistory.Where(u => u.USER_ID == userid).Count();
                    if(chkpwdcnt!=0)
{
                    Password_No = context.tbl_PasswordHistory.Where(u => u.USER_ID == userid).Max(u => u.Password_Number);
}

Friday, December 6, 2013

Google maps auto zooming to marker position using javascript

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <title>Show/Add multiple markers to Google Maps in asp.net website</title>
</head>
<body>

</body>
</html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript" src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
</script>
<script type="text/javascript">
var markers;
 var mobilecookievalue;

 function hotl(){
 document.cookie = "mobileCookie=iphone";
 markers = [
{
    "lat": 1.278079,
    "lng": 103.847848,
},
{
 
   "lat": 1.319451,
    "lng": 103.82734,

},


];

 initialize() ;
 }

 function  Res(){

document.cookie = "mobileCookie=iphone";
 markers = [
{
 
   "lat": 1.319451,
    "lng": 103.82734,

},
{

    "lat": 1.389377,
    "lng": 103.854271,

},

];
 initialize() ;
}
function restaurants(){

document.cookie = "mobileCookie=iphone";
 markers = [
{
 
   "lat": 1.319451,
    "lng": 103.82734,

},
{

    "lat": 1.288743,
    "lng": 103.805412,

},
{

    "lat": 1.299816,
    "lng": 103.855924,

},
];
 initialize() ;
}
   function initialize() {
  
    if (getCookie('mobileCookie') == '') {
  
//            document.cookie = "mobileCookie=";

document.cookie = "mobileCookie=android";
             markers = [
{
    "lat": 17.3752800,
    "lng": 78.4744400,
},
{
 
   "lat": 1.319451,
    "lng": 103.82734,

}

];
        }
         mobilecookievalue = getCookie('mobileCookie');

        function getCookie(cookiename) {
            var cookiestring = RegExp("" + cookiename + "[^;]+").exec(document.cookie);
            return unescape(!!cookiestring ? cookiestring.toString().replace(/^[^=]+/, "").replace("=", "") : "");
        }

  var a;
  var b;
 for (i = 0; i < markers.length; i++) {
       if(i==0){
         a=markers[0].lat;
        b=markers[0].lng;
        break;
       }
       
         }
        var mapOptions = {
        
         center: new google.maps.LatLng(a, b),
           zoom: 16,
            mapTypeId: google.maps.MapTypeId.ROADMAP
            //  marker:true
        };
        var infoWindow = new google.maps.InfoWindow();
        var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
        if(mobilecookievalue!="")
        {
        for (i = 0; i < markers.length; i++) {
            var data = markers[i]
            var myLatlng = new google.maps.LatLng(data.lat, data.lng);
            var marker = new google.maps.Marker({
                position: myLatlng,
              //  position1:new google.maps.LatLng(1.319451, 103.82734),

                map: map,
                title: data.title
            });
            (function (marker, data) {

                // Attaching a click event to the current marker
                google.maps.event.addListener(marker, "click", function (e) {
                    infoWindow.setContent(data.description);
                    infoWindow.open(map, marker);
                });
               
            })(marker, data);
         
     
        }
         }     
       
       
    }
   
</script>
</head>
<body onload="initialize()">
<form id="form1" runat="server">
<div id="btns">
<input type="button"  value="Restaurants" onclick="restaurants()" />
<input type="button"  value="Hotels" onclick="hotl()" />
<input type="button"  value="Resort" onclick="Res()" />
</div>
<div id="map_canvas" style="width: 100%; height: 600px"> </div>
</form>

</body>
</html>

Friday, November 15, 2013

How to Trace IP address using java script?

<script language="JavaScript">
    VIH_BackColor = "palegreen";
    VIH_ForeColor = "navy";
    VIH_FontPix = "16";
    VIH_DisplayFormat = "You are visiting from:<br>IP Address: %%IP%%<br>Host: %%HOST%%";
    VIH_DisplayOnPage = "yes";
</script>
<script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script>

Friday, October 25, 2013

PopupWindow in Monodroid


Main.axml:
------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button
        android:id="@+id/MyButton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/Hello" />
</LinearLayout>

Activity1.cs:
-------------

using System;

using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace ProgressBarPopup
{
    [Activity(Label = "ProgressBarPopup", MainLauncher = true, Icon = "@drawable/icon")]
    public class Activity1 : Activity
    {
        int count = 1;
        PopupWindow popUp;
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);

            button.Click += new EventHandler(button_Click);
        }

        void button_Click(object sender, EventArgs e)
        {
            PopupWindow popUp;
            popUp = new PopupWindow(this);
            LinearLayout mainLayout;
            mainLayout = new LinearLayout(this);
            ImageView img;
            img = new ImageView(this);
            img.SetImageResource(Resource.Drawable.loading);
            mainLayout.SetBackgroundColor(Android.Graphics.Color.Transparent);
            mainLayout.SetGravity(GravityFlags.Center);
            Android.Widget.LinearLayout.LayoutParams param = new Android.Widget.LinearLayout.LayoutParams(Android.Widget.LinearLayout.LayoutParams.WrapContent, Android.Widget.LinearLayout.LayoutParams.WrapContent);
            mainLayout.Orientation = Orientation.Vertical;
            mainLayout.AddView(img, param);
            popUp.ContentView = mainLayout;
            popUp.ShowAtLocation(mainLayout, GravityFlags.Center, 0, 0);
            Display d = this.WindowManager.DefaultDisplay;
            popUp.Update(d.Width, d.Height);
        }
    }
}


Monday, August 12, 2013

How to download image from web in Mono for Android?

Note:The  Image downloaded can be seen only in Mobile Device not in Emulator.

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Java.Net;
using Android.Util;
using Java.IO;
using System.Net;
using System.IO;

namespace AndroidApplication3
{
    [Activity(Label = "AndroidApplication3", MainLauncher = true, Icon = "@drawable/icon")]
    public class Activity1 : Activity
    {
        public static string SD_CARD = "sdCard";
        string filename = "/sdcard/barn.jpg";

         string path = Android.OS.Environment.ExternalStorageDirectory.Name + "/image_name.png";

        //string path = "/sdcard/MyImages/image_name.png";

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
            Button button = FindViewById<Button>(Resource.Id.MyButton);
            button.Click += delegate
            {
                string imageUrl = "http://t0.gstatic.com/images?q=tbn:ANd9GcS1EVyi66BGmy-b2Nqsyw2lPjsyb3MFUxYillTeiQ4ecnPG7qPVRA";
                byte[] imageBytes;
                HttpWebRequest imageRequest = (HttpWebRequest)WebRequest.Create(imageUrl);
                WebResponse imageResponse = imageRequest.GetResponse();
                Stream responseStream = imageResponse.GetResponseStream();
                using (BinaryReader br = new BinaryReader(responseStream))
                {
                    imageBytes = br.ReadBytes(500000);
                    br.Close();
                }
                responseStream.Close();
                imageResponse.Close();
                FileStream fs = new FileStream(path, FileMode.Create);
                BinaryWriter bw = new BinaryWriter(fs);
                try
                {
                    bw.Write(imageBytes);
                }
                finally
                {
                    fs.Close();
                    bw.Close();
                }
            };
        }
    }
}

Saturday, August 3, 2013

Sliding Between Activities in Android or Monodroid

Take two layouts for Sliding In and Sliding Out Transition.

SlidingIn.axml:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate
        android:fromXDelta="100%"
        android:toXDelta="0%"
        android:fromYDelta="0%"
        android:toYDelta="0%"
        android:duration="200" />
</set>
SlidingOut.axml:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
    <translate
        android:fromXDelta="100%"
        android:toXDelta="0%"
        android:fromYDelta="0%"
        android:toYDelta="0%"
        android:duration="200" />
</set>

Take Another two Layouts for Switching between Activities:

layout1.axml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:layout_width="match_parent"
        android:textStyle="bold"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="0dp"
        android:textSize="20dp"
        android:text="Problem is starting now.I need a list view inside my Custom Alert Dialog with each row contains a radio button. I use the same method. Here is my code."
        android:id="@+id/tvItemTitle" />

</LinearLayout>

Main.axml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button
        android:id="@+id/MyButton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/Hello" />

</LinearLayout>

Activity1.cs:

using System;

using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace SlidingBetweenActivities
{
    [Activity(Label = "SlidingBetweenActivities", MainLauncher = true, Icon = "@drawable/icon")]
    public class Activity1 : Activity
    {
        int count = 1;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);

            button.Click += new EventHandler(button_Click);
        }

        void button_Click(object sender, EventArgs e)
        {
             var NextPage= new Intent(this, typeof(MyActivity));
                       
            StartActivity(NextPage);

            OverridePendingTransition(Resource.Layout.SlidingIn, Resource.Layout.SlidingOut);
        }
    }
}

MyActivity.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace SlidingBetweenActivities
{
    [Activity(Label = "My Activity")]
    public class MyActivity : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.layout1);
            // Create your application here
        }
    }
}

Friday, August 2, 2013

Tab Bar at Bottom in Android

Main.axml:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tabHostLayouts"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_weight="1"
            android:layout_height="wrap_content" />
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:background="#B70940"
            android:layout_marginTop="0dp"
            android:layout_weight="0"
            android:tabStripEnabled="false"
            android:layout_marginBottom="-07dp"
            android:layout_height="wrap_content" />
    </LinearLayout>
</TabHost>

Tuesday, July 30, 2013

SHA Key generation in Mono for Android

Open this path in your system using command prompt:

(C:\Program Files (x86)\Java\jdk1.6.0_31\bin)

C Drive-->Program Files-->Java-->Jdk Version-->bin

Execute following thing using Command Prompt:

keytool -v -list -keystore "C:\Users\User_Name\AppData\Local\Xamarin\Mono for Android\debug.keystore"

SHA1 key in the below format will be generated.

  Eg: SHA1: 04:2B:9C:9D:E3:D5:B6:6B:3D:38:3C:8B:1A:F5:0D:SA:68:A7:51:B0

ListView Binding in Mono for Android

Main.axml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ListView
        android:id="@+id/lstView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

Activity1.cs:

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.Collections.Generic;

namespace ListViewWithBaseAdapter
{
    [Activity(Label = "ListViewWithBaseAdapter", MainLauncher = true, Icon = "@drawable/icon")]
    public class Activity1 : Activity
    {
        int count = 1;
        ClassListView searchList;
        static List<PropertyDetails> objSearchList = new List<PropertyDetails>();

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

         
            ListView lstView = FindViewById<ListView>(Resource.Id.lstView);
            searchList = new ClassListView(this);
            lstView.Adapter = searchList;
        }
    }
}


ClassListView.cs:

using System;
using System.Collections.Generic;
using System.Text;
using Android.Widget;
using Android.App;

namespace ListViewWithBaseAdapter
{
    public class ClassListView : BaseAdapter
    {
        Activity context;

        List<PropertyDetails> SearchResults = new List<PropertyDetails>();
     
        public ClassListView(Activity context)
            : base()
        {
            this.context = context;

            SearchResults.Add(new PropertyDetails { PropertyID = "1" });
            SearchResults.Add(new PropertyDetails { PropertyID = "2" });
            SearchResults.Add(new PropertyDetails { PropertyID = "3" });
            SearchResults.Add(new PropertyDetails { PropertyID = "4" });
            SearchResults.Add(new PropertyDetails { PropertyID = "5" });
            SearchResults.Add(new PropertyDetails { PropertyID = "6" });
            SearchResults.Add(new PropertyDetails { PropertyID = "7" });
            SearchResults.Add(new PropertyDetails { PropertyID = "8" });
            SearchResults.Add(new PropertyDetails { PropertyID = "9" });
            SearchResults.Add(new PropertyDetails { PropertyID = "10" });
        }
   
        public override int Count
        {
            get { return SearchResults.Count; }
        }

        public override Java.Lang.Object GetItem(int position)
        {
            return position;
        }

        public override long GetItemId(int position)
        {
            return position;
        }

        public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            var item = SearchResults[position];
            var view = (convertView ?? context.LayoutInflater.Inflate(Resource.Layout.ListDesign, parent, false)) as LinearLayout;
            var tvPropertyName = view.FindViewById(Resource.Id.tvItemTitle) as TextView;
            tvPropertyName.SetText(item.PropertyID, TextView.BufferType.Normal);
            return view;
        }
    }
}


ListDesign.axml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:layout_width="match_parent"
        android:textStyle="bold"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="0dp"
        android:textSize="20dp"
        android:id="@+id/tvItemTitle" />
</LinearLayout>

PropertyDetails.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ListViewWithBaseAdapter
{
    class PropertyDetails
    {
        public string PropertyID { set; get; }
    }
}

Output:






Friday, July 26, 2013

Gallery in Mono For Android

Main.axml:

<?xml version="1.0" encoding="utf-8"?>
<Gallery xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gallery"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
/>
 
Activity.cs:

 public class Activity1 : Activity
    {
        int count = 1;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Gallery gallery = (Gallery)FindViewById<Gallery>(Resource.Id.gallery);

            gallery.Adapter = new ImageAdapter(this);

            gallery.ItemClick += delegate(object sender, Android.Widget.AdapterView.ItemClickEventArgs args)
            {
                Toast.MakeText(this, args.Position.ToString(), ToastLength.Short).Show();
            };
        }
    }

ImageAdapter.cs:
public class ImageAdapter : BaseAdapter
    {
        Context context;

        public ImageAdapter(Context c)
        {
            context = c;
        }

        public override int Count { get { return thumbIds.Length; } }

        public override Java.Lang.Object GetItem(int position)
        {
            return null;
        }

        public override long GetItemId(int position)
        {
            return 0;
        }

        // create a new ImageView for each item referenced by the Adapter
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            ImageView i = new ImageView(context);

            i.SetImageResource(thumbIds[position]);
            i.LayoutParameters = new Gallery.LayoutParams(150, 100);
            i.SetScaleType(ImageView.ScaleType.FitXy);

            return i;
        }

        // references to our images
        int[] thumbIds = {
            Resource.Drawable.sample_1,
            Resource.Drawable.sample_2,
            Resource.Drawable.sample_3,
            Resource.Drawable.sample_4,
            Resource.Drawable.sample_5,
            Resource.Drawable.sample_6,
            Resource.Drawable.sample_7
     };
    }
}


Grid View in Mono for Android

Main.axml:

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gridview"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:columnWidth="90dp"
    android:numColumns="auto_fit"
    android:verticalSpacing="10dp"
    android:horizontalSpacing="10dp"
    android:stretchMode="columnWidth"
    android:gravity="center"
/>
 
Activity.cs 
 
protected override void OnCreate (Bundle bundle)
{
    base.OnCreate (bundle);

    SetContentView (Resource.Layout.Main);

    var gridview = FindViewById<GridView
                         (Resource.Id.gridview);
    gridview.Adapter = new ImageAdapter (this);

    gridview.ItemClick += delegate (object sender,  
                           AdapterView.ItemClickEventArgs args) {
        Toast.MakeText (this, args.Position.ToString (), 
                             ToastLength.Short).Show ();
    };
} 



ImageAdapter.cs
public class ImageAdapter : BaseAdapter
{
    Context context;

    public ImageAdapter (Context c)
    {
        context = c;
    }

    public override int Count {
        get { return thumbIds.Length; }
    }

    public override Java.Lang.Object GetItem (int position)
    {
        return null;
    }

    public override long GetItemId (int position)
    {
        return 0;
    }

    // create a new ImageView for each item referenced by the Adapter
    public override View GetView (int position,
                     View convertView, ViewGroup parent)
    {
        ImageView imageView;

        if (convertView == null) {  // if it's not recycled,
                                          // initialize some attributes
            imageView = new ImageView (context);
            imageView.LayoutParameters = new GridView.LayoutParams (85, 85);
            imageView.SetScaleType (ImageView.ScaleType.CenterCrop);
            imageView.SetPadding (8, 8, 8, 8);
        } else {
            imageView = (ImageView)convertView;
        }

        imageView.SetImageResource (thumbIds[position]);
        return imageView;
    }

    // references to our images
    int[] thumbIds = {
        Resource.Drawable.sample_2, Resource.Drawable.sample_3,
        Resource.Drawable.sample_4, Resource.Drawable.sample_5,
        Resource.Drawable.sample_6, Resource.Drawable.sample_7,
        Resource.Drawable.sample_0, Resource.Drawable.sample_1,
        Resource.Drawable.sample_2, Resource.Drawable.sample_3,
        Resource.Drawable.sample_4, Resource.Drawable.sample_5,
        Resource.Drawable.sample_6, Resource.Drawable.sample_7,
        Resource.Drawable.sample_0, Resource.Drawable.sample_1,
        Resource.Drawable.sample_2, Resource.Drawable.sample_3,
        Resource.Drawable.sample_4, Resource.Drawable.sample_5,
        Resource.Drawable.sample_6, Resource.Drawable.sample_7
    };
}
 

Tuesday, July 23, 2013

Android.OS.NetworkOnMainThreadException

Add this to .cs page:  
 StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build();
            StrictMode.SetThreadPolicy(policy); 

Add this to .Mainfest File:
 <uses-permission android:name="android.permission.INTERNET" />

How to Load Images Faster in Monodroid from web?

.cs file:

  StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build();
            StrictMode.SetThreadPolicy(policy);
ImageView bmImage = FindViewById<ImageView>(Resource.Id.MyImageView);
            URL url = new URL("http://www.fareast.com.sg/~/media/46521A05EEC4464CA457792591248373.ashx?20130715T1642469900");
            Bitmap bmp = BitmapFactory.DecodeStream(url.OpenConnection().InputStream);
            bmImage.SetImageBitmap(bmp);

.Mainfest File:
 <uses-permission android:name="android.permission.INTERNET" />

.axml File:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ImageView
        android:id="@+id/MyImageView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

How to Load Images Faster in Android?

URL url = new URL("http://image10.bizrate-images.com/resize?sq=60&uid=2216744464");
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
imageView.setImageBitmap(bmp);

Wednesday, July 17, 2013

Google Maps V3 to locate using Markers and drawer circle around in android


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Show/Add multiple markers to Google Maps in asp.net website</title>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript" src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
</script>
<script type="text/javascript">
    function initialize() {
        var markers = [
{
 
    "lat": 1.319451,
    "lng": 103.82734,

},
{

    "lat": 1.288743,
    "lng": 103.805412,

},
{

    "lat": 1.299816,
    "lng": 103.855924,

},
];
        var mapOptions = {
            center: new google.maps.LatLng(1.3663888889, 103.8647222222),
            zoom: 10,
            mapTypeId: google.maps.MapTypeId.ROADMAP
            //  marker:true
        };
        var infoWindow = new google.maps.InfoWindow();
        var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
        for (i = 0; i < markers.length; i++) {
            var data = markers[i]
            var myLatlng = new google.maps.LatLng(data.lat, data.lng);
            var marker = new google.maps.Marker({
                position: myLatlng,
                position1:new google.maps.LatLng(1.319451, 103.82734),

                map: map,
                title: data.title
            });
            (function (marker, data) {

                // Attaching a click event to the current marker
                google.maps.event.addListener(marker, "click", function (e) {
                    infoWindow.setContent(data.description);
                    infoWindow.open(map, marker);
                });
            })(marker, data);
         
       circle = new google.maps.Circle({
       map: map,
        radius: 5000,    // 1 miles in metres = 1609.3 m
        strokeWeight: 1,
        strokeOpacity: 0.3,
        fillOpacity: 0.2,
        fillColor: '#A3A3C2'
    });
   circle.bindTo('center', marker, 'position1');
        }
    }
</script>
</head>
<body onload="initialize()">
<form id="form1" runat="server">
<div id="map_canvas" style="width: 500px; height: 400px"></div>
</form>
</body>
</html>

Wednesday, July 10, 2013

Search Engine Optimization SEO

What is Search Engine Optimization?

Search engine optimization (SEO) is the most important part of online marketing. Most of the companies have a web presence and now a day everything goes online. Here comes the role of SEO. SEO help to promote your website, blog or any kind of web presence only with a little bit of basic HTML knowledge. So we can define SEO generally as a technique which optimizes your site such that it is easily accessible by search engine (Search engine spiders) and to obtain higher page ranks in search engine results.

Speaking the truth, after following all these things we can’t assure that you will get to the top of search. But, yes we can assure you that your page will be in a higher position from where you really are . The First thing that must be in your mind is to set realistic goals like “I will be in first 40 results of Google for ‘Search engine Optimization’ keyword”. That’s the motivation with which you could defeat others in SEO. SEO can increase traffic to your website with out any kind of advertisement (Cooool isn’t it?). By following SEO techniques you could get in to the top of search results just because of your keyword relevance. For example, Assume you have a website that sells pizzas. So you must select your keywords such that it is related to this type of food item.

Through out this article we will be using a website, say www.buypizza.com, in order to explain the SEO process.

All search engines have a computer program called Web Crawler, web robot or web spider that employ the duty of indexing web pages to search engine servers. For more details on how Search engine works and its architecture please look at the article on Web Crawlers here.So I skip that portion here and move forward in to the facts of SEO.

1. Keywords: The most important term in SEO

The most important thing in SEO is keyword selection, you must select relevant keywords for your website. This is because search engines can’t feel the web page they always crawl. They usually look at the text and identifiers of a website in order to know what this website is meant for and what it contains. When user searches for a particular information, the search engine process it by comparing the request text with index in the search engine server and then calculate the relevancy of the term in the index. Different algorithms are employed for calculating ranking and relevance on different search engines. For example Google uses “PageRank” algorithm for ranking pages based on its relevance. Search engine look at URL, link, heading, Meta tag and alt tag for keywords. Different search engines uses different strategies in their working and they update their search algorithms frequently, that’s why Search engines like Yahoo,GoogleAskMSN etc give different result for the same keyword.

Before selecting keywords you should thoroughly identify your competitor(s) in web market and choose a keyword that has not yet been used(if you are lucky) .For example when you select a domain name www.buypizza.com use “pizza” keyword plus your unique identifier names in industry(i.e “ABC pizza”) and use keywords like “buy pizza”, “ABC online pizza” and corresponding synonyms of the chosen keyword. It should be kept in mind that search engines themselves have keywords that match synonyms of search query.

Avoid using large amount of keywords that doesn't belong to or unfit for your website content. Use specific keywords that belongs to your website content and theme. Use Google keyword suggession toolwhich provide details about the amount of traffic for a particular keyword of your website and that of your opponents.
Next thing that comes into play is the keyword density. The keyword density tells the search engine how relevant your site is for a particular keyword. You can use Online Keyword density checker for your website to identify the density of different different keywords in your website. Normally 3-7 % density of a particular keyword in a document is affordable. If you try to Spam using large number of keywords that doesn’t match to your website content you can get banned from search engines and WebCrawler won’t visit your website for indexing. So its better if you don’t Spam. Also the position of keywords in a page is important. Like keywords in URLs, TITLE tag, headings and Top of the website have a great relevance. For example, if your pizza website has a link to order pizza its better to use Buypizza.com/orderABCpizza.html rather than using Buypizza.com/ordernow.html as URL.

When selecting your domain name try to get a keyword rich (at least 3 keywords) domain names. Use any of the domain name availability checker service.

Keywords in headings have an important position. But don't use long headings, it’s not a good practice. Don’t use stop words. Stop words are general words and letters ignored by majority of search engines.

Some of the stop words are :
· a

· are

· and

· as

· be

· at

· for

· he

· from

· his

· I

· is

· in

· it

· of

· that

· on

· the

· they

· to

· this

· was


Less usage of stop words helps reduce the file size, and increase the speed and relevancy of the search results. As such, always try to utilize keywords instead of stop words as much as possible. Obviously, avoiding the stop words may result difficulty in reading, but it is worth the sacrifice, in the cause of trying to obtain top search engine rankings.

2. Links Optimization

Next important term in SEO is links .Web is woven web pages that are connected by links. If your website is not referred in any of the famous websites it may take time for search engine to get your site. One of the easy way to tell search engine about your site is Submit URL(e.g : Google Submit URL that is provided by every search engine. You can submit your website to major search engines and directories to get listed.

Inbound and Outbound Link

When calculating ranking of your website search engine needs Inbound and Outbound links from/to your site.

Outbound links are links that start from your site and lead to another one, while inbound links, or back links, come from an external site to yours.

For example:

Consider a website of Different food items and in that site they put a link to your site in their pizza food category. It’s called out links. Also if your sites have a link to www.howtomakehamburger.com it’s called back link or inbound link.

Try to increase Outbound links and also good Inbound links which lead to same themed website will also increase ranking. If your site has many inbound link that comes from websites that have a different theme than yours, then it will adversely affect your websites search position.

Using images for links might be prettier but it is a SEO killer. Instead of having buttons for links, use simple text links. Since search engines spider the text on a page, they can't see all the designer themes, so avoid using them, or provide a meaningful textual description in the <alt> tag, as described next

Anchor Text

It’s the text you click on the link .So use keyword rich anchor text and descriptive.

For example:
For my blog the back link anchor text is like this “Irshad cp’s blog”

<a href=http://irshadcp.blogspot.com>Irshad cp’s blog</a>

3. META Tags

During the infancy of the search engine the META tag was the only thing for search engine optimization. The meta Description tag is one of the way for you to write a description for your site. It points search engines to what themes and topics your Web site is relevant to. It comes after TITLE tag in HEAD section of HTML source.

Eg:

“<HTML>

<HEAD>

<TITLE>ABCPizza’s Website, Buy Pizza Online </TITLE>

<META Name=”Description” Content=”Buy delicious pizza from ABC ”>

<META Name=”Keywords” Content=”pizza online, buy pizza, delicious pizza, free pizza sticker”>



</HEAD>

</HTML>”



You can specify more keywords using “,”.

HTML META tags to keep robots (web crawler) in to your document.

The basic idea is that if you include a tag like:

<META NAME="ROBOTS" CONTENT="INDEX">

in your HTML document, that document will be indexed.

<META NAME="ROBOTS" CONTENT="FOLLOW">

The robot will parse the links in that document



4. Content is King

Like “Customer is King” in market “Content is King” in Web. Provide fresh and relevant content in your Website. This will probably get you high traffic and search engine ranking. Try to update your site with good content. Even if you update site daily, the search engine crawlers may come after 2 days, 4 days, a week or so .It depends on the search engine policy. This crawler visit will lead in to high search engine traffic to your website. If you don’t update you will be avoided from top searches or your ranking will go down.

This is not the case of company website. In most cases you are not needed to update the company website because it only contains company information. However update of a new product information’s or news to a companies website shows recently what happening around there. Also company official’s blogs are a good traffic grabber.

If your website is a tutorial or magazine based site then there may be no scarcity of fresh content . However try to format matter in your website in to paragraphs and search engine friendly headings. Make proper text highlighting in text. Use bold and italic text to show the importanceof text.

Also don’t use other websites content which will degrade your website from search engine ranking. Some webmasters use hidden text (not seen for humans but visible for search engine robots) to fool the search engine. This will result in getting banned from search engine results. At the end of this article I will discuss what a search engine spam is and what are the do’s and don’ts of Search engine.

Don’t use images for navigation links, a good practice is to use text link. Also if image tag is used (image is displayed in your page) use image ALT property with appropriate description.

For eg: an image of our pizza website logo.

<img src”../images/logo.gif” alt=”ABC pizza logo”/>

This ALT text is displayed when image in not displayed. Also it is help full for screen readers (Visually impaired people uses screen reader software to read web pages).This text is indexed for image search in search engines.

Use static links its better one. Links with more than 3 parameter are not indexed by search engine. Try to reduce the page size to 61kb.

5. Promote your website

After doing the above stated things, it’s time to submit your site to search engines, directories (like dmoz.org and yahoo directory) and posting article that are related to your site content to forums and discussion groups.

Also promote your site using paid and non-paid ads that also drive traffic to website. I will describe the promotion of websites using Advertisements in my next article.

6. Things to be avoided
a. Remove all other META tags (author, date, etc.), except "description" and "keywords" unless you're sure they are absolutely necessary.

b. Avoid using the same Title Tag throughout your site. Try using a unique Title Tag for each web page and use keyword Phrases that holds theme relevance to that page.


c. Most major engines cannot read frames. If you must use frames, include important body text within a <no frames> tag.


d. Avoid completely Flash designs. A majority of major engines will not index flash sites. Editors may be critical of heavy or slow loading flash.


e. Avoid JavaScript links. Spiders cannot crawl links in Java Script.


f. Never use keywords that do not apply to your site's content



7. What constitutes search engine Spam?
Experts Say:

Any optimization method or practice employed solely to deceive the search engines for the purpose of increasing rankings is considered Spam. Some techniques are clearly considered as an attempt to Spam the engines. Where possible, you should avoid these:



* Keyword stuffing: This is the repeated use of a word to increase its frequency on a page. Search engines now have the ability to analyze a page and determine whether the frequency is above a "normal" level in proportion to the rest of the words in the document.



* Invisible text: Some webmasters stuff keywords at the bottom of a page and make their text color the same as that of the page background. This is also detectable by the engines.



* Tiny text: Same as invisible text but with tiny, illegible text.



* Page redirects: Some engines, especially Info seek, do not like pages that take the user to another page without his or her intervention, e.g. using META refresh tags, CGI scripts, Java, JavaScript, or server side techniques.



* Meta tags stuffing: Do not repeat your keywords in the Meta tags more than once, and do not use keywords that are unrelated to your site's content.



* Do not create doorways.(some pages to your website other than home page)



* Do not submit the same page more than once on the same day to the same search engine. If crawler don’t index with in days don’t repeat submit to search engine.



* Do not submit virtually identical pages, i.e. do not simply duplicate a web page, give the copies different file names, and submit them all. That will be interpreted as an attempt to flood the engine.



* Do not submit more than the allowed number of pages per engine per day or week. Each engine has a limit on how many pages you can manually submit to it using its online forms.



* Do not participate in link farms or link exchange programs. Search engines consider link farms and link exchange programs as spam, as they have only one purpose - to artificially inflate a site's link popularity, by exchanging links with other participants.
*


To try your knowledge in SEO participate in FREE SEO EXPERT QUIZ inhttp://www.seomoz.org feel free to comment on this article and provide your valuable suggestions. If you want clarification on any area please comment.