javascript - Create a java script function in c# -


i'm developing winform application , want use google api v3 calculate barycenter of polygon. , have lng , lat in database. want call java script function in c# i'm new found using htmlelement can me here code tried doesn't give result.

webbrowser webbrowser1 = new webbrowser();         string url = ("c:\\users/guenafai/desktop/topapplication/topapplication/baryscripts.htm");         console.writeline("je suis laaaaaaaaaaaa");         webbrowser1.navigate(url);         htmlelement head = webbrowser1.document.createelement("head");         htmlelement scriptel = webbrowser1.document.createelement("script");         scriptel.setattribute("src","https://maps.googleapis.com/maps/api/js?key=aizasyaxby6ydvnzou0tk2rkrdmbnebn3gn1svk");         ihtmlscriptelement element = (ihtmlscriptelement)scriptel.domelement;         string script = @"         function baryc(){             var boundss = new google.maps.latlngbounds();             var i;             var polygoncoords = [";             foreach (contract c in clus)             {                 script = script + @"             new google.maps.latlng(" + 45.501689 + "," + -73.567256 + @"),"             }             script = script + @"new google.maps.latlng(" + 45.501689 + "," + -73.567256 + @")];              (i = 0; < polygoncoords.length; i++) {                 boundss.extend(polygoncoords[i]);             }             var lat = boundss.getcenter().lat() ;             var lng = boundss.getcenter().lng();             return boundss.getcenter().tostring() ;          }";         console.writeline(script);         element.text = script;         head.appendchild(scriptel);         string onclickstring = (string)webbrowser1.document.invokescript("baryc");         console.writeline(onclickstring); 

i used api c# instead http://www.codeproject.com/articles/32643/gmap-net-great-maps-for-windows-forms-and-presenta


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -