c# windows form & google api v3
-
hi all, i use c# windows form application & i want to change latitude & longitude in google api v3 JavaScript code var myLatlng = new google.maps.LatLng(30.050144, 31.240042); according to C# form latitude text box & longitude text box entered value I can display the page in webbrowser control but it's static how can i do this??? thanks in advance
-
hi all, i use c# windows form application & i want to change latitude & longitude in google api v3 JavaScript code var myLatlng = new google.maps.LatLng(30.050144, 31.240042); according to C# form latitude text box & longitude text box entered value I can display the page in webbrowser control but it's static how can i do this??? thanks in advance
This is the third time you have asked this question but you have not explained which part does not work.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
-
This is the third time you have asked this question but you have not explained which part does not work.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
var myLatlng = new google.maps.LatLng(30.050144, 31.240042); this javascript code works but, i want to replace the static values of latitude (30.050144) & longitude (31.240042) in javascript code with any value entered by user in latitude textbox & longitude textbox
-
var myLatlng = new google.maps.LatLng(30.050144, 31.240042); this javascript code works but, i want to replace the static values of latitude (30.050144) & longitude (31.240042) in javascript code with any value entered by user in latitude textbox & longitude textbox
this code i use in html page <%--!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> --%> html { height: 100% } body { height: 100%; margin: 0; padding: 0 } #map_canvas { height: 100% } function initialize() { var myOptions = { center: new google.maps.LatLng(30.04866, 31.23688), zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var myLatlng = new google.maps.LatLng(30.050144, 31.240042); var myOptions = { zoom: 20, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var marker = new google.maps.Marker({ position: myLatlng, map: map, title: "Hello World!" }); }
& this code i have used in c# form StringBuilder queryAddress = new StringBuilder(); queryAddress.Append("file:///C:/Users/mrx1000/documents/visual studio 2010/Projects/testgoogleapi3/testgoogleapi/HTMLPage1.htm"); webBrowser1.Navigate(queryAddress.ToString()); this image for my form in running http://www.mediafire.com/?rqckg28xb4rlahb as you see i didn't enter anything in latitude text box or longitude text box i find away but it's very difficult in this example & when i use it gives me errors // webBrowser1.DocumentText = //"" + //"function test(message) { alert(message); }" + //"" + //""; what i should i do now?
-
hi all, i use c# windows form application & i want to change latitude & longitude in google api v3 JavaScript code var myLatlng = new google.maps.LatLng(30.050144, 31.240042); according to C# form latitude text box & longitude text box entered value I can display the page in webbrowser control but it's static how can i do this??? thanks in advance
Your C# WinForm application with webbrowser control embedded in the form can use the following ways to achieve two-way communication between your C# code and the JavaScript code loaded by the webbrowser control. From JavaScript to C#, follow these steps: 1. Create a member function in C#. In this example, suppose we have a function called "report_location":
public void **report\_location**(double latitude, double longitude) { //you can do whatever you want to do in your C# function here }
2. From your JavaScript code whenever you need to call the above C# function, do it like this:
window.external.**report\_location**(...);
In the above function call the "
**...**
" represents the arguments you pass to the function. Use whatever arguments you need to use. For example if you are using Google Maps API and you add a listener to the map's click event, the function will be like this:google.maps.event.addListener( map, 'click', function(event){ window.external.**report\_location**( event.latLng.lat(), event.latLng.lng() ); } );
Your C# code will be able to get the clicked location's latitude/longitude. From C# to JavaScript, follow these steps: (These will answer your specific question.) 1. In your JavaScript code create a function. In this example, suppose we have a function called "set_location":
function **set\_location**(latitude, longitude){ //this is your existing statement //var myLatlng = new google.maps.LatLng(30.050144, 31.240042); //this is the new statement var myLatlng = new google.maps.LatLng(latitude, longitude); //do whatever you want to do... }
2. In your C# code whenever you need to call the above function to set the location, do it like this (suppose your webbrowser control is represented by the variable
**wb_map**
:wb\_map.Document.InvokeScript( "**set\_location**", new string\[\]{ "30.050144", "31.240042" } );
Of course if the numbers are stored in variables such as
**latitude**
,**longitude**
, the above call will bewb\_map.Document.InvokeScript( "**set\_location**", new string\[\]{ latitude.ToString(), longitude.ToString() } );
Hope this answers your question. Happy programming!
-
Your C# WinForm application with webbrowser control embedded in the form can use the following ways to achieve two-way communication between your C# code and the JavaScript code loaded by the webbrowser control. From JavaScript to C#, follow these steps: 1. Create a member function in C#. In this example, suppose we have a function called "report_location":
public void **report\_location**(double latitude, double longitude) { //you can do whatever you want to do in your C# function here }
2. From your JavaScript code whenever you need to call the above C# function, do it like this:
window.external.**report\_location**(...);
In the above function call the "
**...**
" represents the arguments you pass to the function. Use whatever arguments you need to use. For example if you are using Google Maps API and you add a listener to the map's click event, the function will be like this:google.maps.event.addListener( map, 'click', function(event){ window.external.**report\_location**( event.latLng.lat(), event.latLng.lng() ); } );
Your C# code will be able to get the clicked location's latitude/longitude. From C# to JavaScript, follow these steps: (These will answer your specific question.) 1. In your JavaScript code create a function. In this example, suppose we have a function called "set_location":
function **set\_location**(latitude, longitude){ //this is your existing statement //var myLatlng = new google.maps.LatLng(30.050144, 31.240042); //this is the new statement var myLatlng = new google.maps.LatLng(latitude, longitude); //do whatever you want to do... }
2. In your C# code whenever you need to call the above function to set the location, do it like this (suppose your webbrowser control is represented by the variable
**wb_map**
:wb\_map.Document.InvokeScript( "**set\_location**", new string\[\]{ "30.050144", "31.240042" } );
Of course if the numbers are stored in variables such as
**latitude**
,**longitude**
, the above call will bewb\_map.Document.InvokeScript( "**set\_location**", new string\[\]{ latitude.ToString(), longitude.ToString() } );
Hope this answers your question. Happy programming!
-
loyal ginger wrote:
wb_map.Document.InvokeScript( "set_location", new string[]{ "30.050144", "31.240042" } );
thanks for this simple & great answer but when i use this code i have this error object reference not set to an instance of an object
In my example,
wb_map
is theWebBrowser
control on the Form. You need to replace it with theWebBrowser
control in your application. -
In my example,
wb_map
is theWebBrowser
control on the Form. You need to replace it with theWebBrowser
control in your application.loyal ginger wrote:
In my example,
wb_map
is theWebBrowser
control on the Form. You need to replace it with theWebBrowser
control in your applicationof course i replace wb_map by webBrowser1 control but i have error i don't know what causes this error object reference not set to an instance of an object ????!!!!!!!!!!!
-
loyal ginger wrote:
In my example,
wb_map
is theWebBrowser
control on the Form. You need to replace it with theWebBrowser
control in your applicationof course i replace wb_map by webBrowser1 control but i have error i don't know what causes this error object reference not set to an instance of an object ????!!!!!!!!!!!
Sorry I might have misunderstood you. In that case I really have no clue what went wrong. My original reply to your question was based on my error-free application, which happens to be very similar to your program. I don't have a complete picture of your program so it's hard for me to trouble shoot your program. Maybe somebody else here can give you a better answer? Thanks for your patience!
-
Sorry I might have misunderstood you. In that case I really have no clue what went wrong. My original reply to your question was based on my error-free application, which happens to be very similar to your program. I don't have a complete picture of your program so it's hard for me to trouble shoot your program. Maybe somebody else here can give you a better answer? Thanks for your patience!