Skip to main content

Posts

Showing posts from July, 2016

C#: Geocoding to get Latitude and Longitude using Google Maps API

Geocoding is the process of getting the latitude and longitude of an address or set of addresses, which you can use to place markers or position the map.
Geocoding can be done on client side as well as on server side, based on your requirements you need to choose one out of both options.
For geocoding I am using Google Maps API which is quite reliable and faster in response to other geocoding APIs.
You can check the JSON response by directly running the API with address on browser window or you can take service of POSTMAN as well. Sample JSON response of Google Map API is given below:
Requested geocoding of “Gurgaon” using Google Maps API Request: http://maps.googleapis.com/maps/api/geocode/json?sensor=true&address=Gurgaon Response: { "results" : [        { "address_components" : [               { "long_name" : "Gurgaon", "short_name" : "Gurgaon", "types" : [ "locality", "political" ]               },     …

SQL Server: Storing language specific data in SQL Server table field.

While working on multi language support we need to insert different language data in same field or different fields of a SQL server table.
There are two basic rules one need to keep in mind while storing multi lingual or Unicode data: ·First is column must be of Unicode data type (i.e., nchar, nvarchar, ntext). ·And second is that the value must be prefixed with N while insertion.
Below is the sample script with output to understand it better. USEMASTER GO -- Drop and Create TestMultiLingualDB IFdb_id('TestMultiLingualDB')ISNOTNULL DROPDATABASE TestMultiLingualDB GO SETNOCOUNTON GO CREATEDATABASE TestMultiLingualDB GO USE TestMultiLingualDB GO CREATETABLE MultiLanguage(Id INT, Var_Field VARCHAR(50), NVar_Field NVARCHAR(50)) GO -- Insert Hindi Characters INSERTINTO MultiLanguage VALUES (1,N'यहएकशब्दहै',N'यहएकशब्द

Knockoutjs check/uncheck all checkboxes using header checkbox.

While working with Knockoutjs ViewModel, if we implement the select all checkbox feature using traditional JavaScript/JQuery, then in such scenario we can see that Knockoutjs observable property is not getting updated when all checkboxes are checked/unchecked.
To handle such situation, we can create Knockoutjs computed property (with read/write) and can bind it to header checkbox and there is no need to use the traditional JQuery. Below is the sample code to demonstrate the same:
As usual create the Knockoutjs ViewModel and then bind it to UI usingko.applyBindings function CheckViewModel() { var self = this;     self.Countries = ko.observableArray(                                                       [ new Country("Australia"), new Country("India"), new Country("Russia"), new Country("United Kingdom"), new Country("United States")                                                ]);
self.SelectAll = ko.computed({         read: function () { var co…