Posts

Showing posts from December, 2013

Geo Location - Get location based on where you are

Hi, Today i am going to share script how to get location based on where you are located.  Here is the script, <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>GMap location</title> <script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"> </script> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script> $(document).ready(function() {  navigator.geolocation.getCurrentPosition(function (pos) {     var geocoder = new google.maps.Geocoder();     var lat = pos.coords.latitude;     var lng = pos.coords.longitude;     var latlng = new google.maps.LatLng(lat, lng);      //reverse geocode the coordinates, returning location information.     geocoder.geocode({ 'latLng': latlng }, function (results, st...

Javascript function to display 2 digit number

Hi, Today i am going to share how to display 2 digit number in javascript and jQuery, Javascript: ------------- function twodigit(num) {          var num1 = parseInt(num, 10);           return num1 < 10 ? "0" + num1 : num1;     } JQuery: --------- $('#count').text(function(i,num) {   var num1 = parseInt(num, 10);   return num1 < 10 ? "0" + num1 : num1; }); Output: ---------- twodigit(1); // returns 01 twodigit(2); // returns 02

Upload folder for images

Image
Here i am going to explain how to upload folder instead of files. For that we need to add  webkitdirectory=""  inside the input tag in HTML For eg, <input type="file" name="file_input[]" id="file_input" multiple="" webkitdirectory=""> Output:

GMap Location Pointer based on Longitude and Latitude

Image
In this post, i am going to share how to display gmap pointer based on longitude and latitude. Here is the code, <!DOCTYPE html> <html> <head>   <meta http-equiv="content-type" content="text/html; charset=UTF-8">   <title> GMap location </title>   <script type='text/javascript' src="http://maps.google.com/maps/api/js?sensor=false&.js"></script>   <style type='text/css'>     #map_canvas{         width: 600px;         height: 500px;     }   </style>   </head> <body> <div id="map_canvas"></div> <script type='text/javascript'>//<![CDATA[ var map; var global_markers = [];    var markers = [[37.09024, -95.712891, 'trialhead0'], [-14.235004, -51.92528, 'trialhead1'], [-38.416097, -63.616672, 'trialhead2']]; var infowindow = new google.map...

Array to JSON

To display array values in JSON format, you need to use json_encode(). For eg: $arr = array('username' => 'test','userid' =>'1', 'password' => 'test123'); // Use json_encode to return in json format echo json_encode($arr); Output: {"username":"sham dhar","userid":"36","password":"test123"}