jQuery google map plugin

jQuery google map plugin

Create Plugin.

PS: Please include jquery & map library in header

(function($){
    $.fn.gMap = function(options){
    var opts = $.extend({},$.fn.gMap.defaults,options);
    var mapOptions = {
        center: new google.maps.LatLng(opts.latCenter, opts.longCenter)
    };
   $.extend(opts,mapOptions);
   var map = new google.maps.Map(document.getElementById(opts.elementId),opts);
};
$.fn.gMap.defaults={"latCenter":"23.0235","longCenter":"72.624","zoom":8,"mapTypeId":"roadmap"};
})(jQuery);

Call your plugin

jQuery(document).ready(function($){
 $('map-canvas').gMap({
    "elementId":"map-canvas",
});
});

Creating custom JQuery plugin

Creating custom JQuery plugin

Introduction

The jQuery library is designed to speed up JavaScript development. It helps you write less code by simplifying the way you write JavaScript. When using the jQuery library, you might find that you rewrite the same code for common functions. If this is the case, this may be a reason for you to write your own custom jQuery plug-in.

Prerequisites

This article assumes you have a basic understanding of JavaScript, jQuery,html.you can see complete code below

Getting Started

Step 1 : Define your plugin name. For eg : myplugin

    $.fn.myplugin = function() {
     return this.each(function() {
        //Write your logic here.
     });
    };

jQuery keyword is applied to the wrapper function, which lets you use the dollar sign within the plug-in as you do when using the fn property. With the wrapper function in place, you can use the dollar sign in lieu of the jQuery keyword anywhere throughout the plug-in without interfering with other third-party plug-ins.

Step 3 : Build your logic :

For eg-  I click any child  element for a element they will be hiden. We find all child and bind a custom function “hideElement” function on click event.



(function($) {
   $.fn.myplugin = function() {
    return this.each(function() {
      var ele = $(this).children();
       ele.click(hideElement);
    });
   function hideElement() {
      $(this).hide();
      return false;
   }
}
})(jQuery);

Step 4 :use your plugin


$(document).ready(function() {	 	 
   $("div#container").myplugin();	 	 
});
 

Download older version of wordpress plugin

Would you ever like to download older version of wordpress plugin? Here is explanation with example WP-Commecre http://wordpress.org/extend/plugins/wp-e-commerce/

Step 1) Open a plugin page & see download link

http://downloads.wordpress.org/plugin/wp-e-commerce.3.8.11.1.zip

Open this from browser http://downloads.wordpress.org/plugin/wp-e-commerce.3.8.11.1.zip

Step 2) Copy url & replace version from url with any valid one.For eg. 3.8.9

Url become http://downloads.wordpress.org/plugin/wp-e-commerce.3.8.9.zip

Download it from new url.

Thanks