IT Community - Software Programming, Web Development and Technical Support

How to include Google earth in winforms of c# application

This is a discussion on How to include Google earth in winforms of c# application within the C# Programming forums, part of the Software Development category; hi all, i am trying to include google earth in my application, it works fine in asp.net where i ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 08-08-2007, 12:48 AM
smani smani is offline
D-Web Programmer
 
Join Date: Aug 2007
Posts: 56
smani is on a distinguished road
Question How to include Google earth in winforms of c# application

hi all,
i am trying to include google earth in my application, it works fine in asp.net where i used javascript to include it.
but in case of winforms(windows application), i had created user controls for google earth map, and used that control in my form, but while i running my application it parallely starting the googleearthplus application also, and also display the same in my form also, if i closed the googleearthplus application, control in my form also get disappear..
is any other way yo include the google earth in our winforms or any other solution for this?

Thanks
Manivannan.s
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-08-2007, 01:43 AM
smani smani is offline
D-Web Programmer
 
Join Date: Aug 2007
Posts: 56
smani is on a distinguished road
Default Re: How to include Google earth in winforms of c# application

hi friends,
i had find the way to include google map in my winform

add webbrowser control to form
then in load event

webBrowser1.Navigate("http://maps.google.com/maps");

add this code

if u know any functionality to add marker, mapping places..etc in google map
post here.. its helpful for me

Thanks
Manivannan.s
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-09-2007, 05:10 AM
GDevakii GDevakii is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 138
GDevakii is on a distinguished road
Question Re: How to include Google earth in winforms of c# application

hi
but in this way, some extra details of google site is also coming, eg: signin,search..etc

is any solution to override this problem

Regards
Devaki
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-09-2007, 05:30 AM
smani smani is offline
D-Web Programmer
 
Join Date: Aug 2007
Posts: 56
smani is on a distinguished road
Post Re: How to include Google earth in winforms of c# application

hi,
yes, but we need to create one own website, in that we need to integrate
the google map using javascript, for that we need to signup in google to get
API key,

here is the example code to include google map in our site:
<script src="http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAeN_LhMOi4FsadGt6q2yJ qRRi-exo-90g1z9p2Z9OroAhcfs0axTr-W4zx9cE4tcCyp6mf1TJ2QiIAA" type="text/javascript"></script>


<script type="text/javascript">

function load() {
if (GBrowserIsCompatible()) {
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(51.179045, -1.826752), 14);
var point = new GLatLng(51.17904, -1.826752);
var marker = new GMarker(point);
map.addOverlay(marker);
}
}
//]]>


</script>

<html>
<body>
<div id="map" style="width: 900px; height: 500px;"></div>
</body>
</html>


it will help you to create your own google map for ur site, after that
create a windows application, split the windows as per ur requirement,
add webbrowser to it, and

onloading of form give

webbrowser1.navigate("http://")//ur site url

Regards
Manivannan.s
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-09-2007, 07:12 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Question Re: How to include Google earth in winforms of c# application

hi

is it possible to change the marker image over the map, any idea?
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 08-09-2007, 08:00 AM
rrrajesh84in rrrajesh84in is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 399
rrrajesh84in is on a distinguished road
Default Re: How to include Google earth in winforms of c# application

Quote:
Originally Posted by smani View Post
hi friends,
i had find the way to include google map in my winform

add webbrowser control to form
then in load event

webBrowser1.Navigate("http://maps.google.com/maps");

add this code

if u know any functionality to add marker, mapping places..etc in google map
post here.. its helpful for me

Thanks
Manivannan.s

hi

check this link it helps u..

Google Earth COM API Documentation
__________________
.....................................
''''''
Rajesh''''''
Ants. . . . . . Like me
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 08-09-2007, 11:54 PM
smani smani is offline
D-Web Programmer
 
Join Date: Aug 2007
Posts: 56
smani is on a distinguished road
Post Re: How to include Google earth in winforms of c# application

Quote:
Originally Posted by kingmaker View Post
hi

is it possible to change the marker image over the map, any idea?
yes, possible
Quote:
Originally Posted by smani View Post
<script src="http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAeN_LhMOi4FsadGt6q2yJ qRRi-exo-90g1z9p2Z9OroAhcfs0axTr-W4zx9cE4tcCyp6mf1TJ2QiIAA" type="text/javascript"></script>


<script type="text/javascript">

function load() {
if (GBrowserIsCompatible()) {
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(51.179045, -1.826752), 14);
var point = new GLatLng(51.17904, -1.826752);
var marker = new GMarker(point);
map.addOverlay(marker);
}
}
//]]>

</script>

<html>
<body>
<div id="map" style="width: 900px; height: 500px;"></div>
</body>
</html>
try this code's(add this code to the above code)
var map = new GMap(document.getElementById("map"));
map.centerAndZoom(new GPoint(-92.27722, 34.74875), 4);
map.addControl(new GSmallMapControl());

map.addControl(new GMapTypeControl());
var point = new GPoint(-92.27722, 34.74875);
var blueIcon = new GIcon();
blueIcon.iconAnchor = new GPoint(9, 34);
blueIcon.image = "http://localhost:1661/map/Arrow.gif";
blueIcon.iconSize = new GSize(20, 34);
blueIcon.infoWindowAnchor = new GPoint(9, 2);
var Icons=[];
Icons[0] = blueIcon;
var marker = new GMarker(point,Icons[0]);
map.addOverlay(marker);

give HTTP url to the image icon

Regards
Manivannan.s
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-10-2007, 12:01 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: How to include Google earth in winforms of c# application

hi,
how to retrieve the longitude and latitude of the position onclick?
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 08-10-2007, 02:34 AM
smani smani is offline
D-Web Programmer
 
Join Date: Aug 2007
Posts: 56
smani is on a distinguished road
Post Re: How to include Google earth in winforms of c# application

Quote:
Originally Posted by kingmaker View Post
hi,
how to retrieve the longitude and latitude of the position onclick?
use this code to retrieve longitude and latitude

<script type="text/javascript">
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(51.179045, -1.826752), 14);
var point = new GLatLng(51.17904, -1.826752);
var marker = new GMarker(point);
map.addOverlay(marker);

GEvent.addListener(map, 'click', function(overlay, point) {

if (overlay) {
map.removeOverlay(overlay);

} else if (point) {

map.recenterOrPanToLatLng(point);
var marker = new GMarker(point);
map.addOverlay(marker);
document.getElementById("latbox").value=point.y;
document.getElementById("lonbox").value=point.x;


}

});

}
}
//]]>


</script>

<body onload="load()" bgcolor="gray" onunload="GUnload()">
<div align="center" style="vertical-align:middle;">
<div id="map" style="width: 900px; height: 500px;"></div>
<table align="center">
<TR><TD ALIGN="left"> Lat: </TD><TD><INPUT SIZE=13 TYPE="TEXT" ID="latbox" NAME="lat" value="" ></TD></TR>
<TR><TD ALIGN="left">Lon: </TD><TD><INPUT SIZE=13 TYPE="TEXT" ID="lonbox" NAME="lon" value="" ></TD></TR>
</table>
</div>
</body>


Regards
Manivannan.s
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 08-10-2007, 03:06 AM
GDevakii GDevakii is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 138
GDevakii is on a distinguished road
Question Re: How to include Google earth in winforms of c# application

hi,
The above code helps to remove the marker from map, i am searching for it for a long time, thanks

but i am facing a problem with icon,
Quote:
blueIcon.iconAnchor = new GPoint(9, 34);
blueIcon.image = "http://localhost:1661/map/Arrow.gif";
blueIcon.iconSize = new GSize(20, 34);
blueIcon.infoWindowAnchor = new GPoint(9, 2);
var Icons=[];
Icons[0] = blueIcon;
var marker = new GMarker(point,Icons[0]);
from the above code it generating the icon correctly only on load means only the first icon come as our wish.. how to change further icons also?

Thank you
G.Devaki
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 08-10-2007, 04:23 AM
smani smani is offline
D-Web Programmer
 
Join Date: Aug 2007
Posts: 56
smani is on a distinguished road
Default Re: How to include Google earth in winforms of c# application

Quote:
Originally Posted by GDevakii View Post
hi,
The above code helps to remove the marker from map, i am searching for it for a long time, thanks

but i am facing a problem with icon,


from the above code it generating the icon correctly only on load means only the first icon come as our wish.. how to change further icons also?

Thank you
G.Devaki
hi, here is the new code, it will help u, it will generate new marker when u click on map with ur icon
<script type="text/javascript">
//<![CDATA[

var map = new GMap(document.getElementById("map"));
map.centerAndZoom(new GPoint(-92.27722, 34.74875), 4);
map.addControl(new GSmallMapControl());

map.addControl(new GMapTypeControl());
var point = new GPoint(-92.27722, 34.74875);

var blueIcon = new GIcon();
blueIcon.iconAnchor = new GPoint(9, 34);
blueIcon.image = "http://localhost:1661/map/Arrow.gif";
blueIcon.iconSize = new GSize(20, 34);
blueIcon.infoWindowAnchor = new GPoint(9, 2);


var Icons=[];
Icons[0] = blueIcon;

var marker = new GMarker(point,Icons[0]);
map.addOverlay(marker);
GEvent.addListener(map, 'click', function(overlay, point) {

if (overlay) {
map.removeOverlay(overlay);

} else if (point) {
map.recenterOrPanToLatLng(point);
document.getElementById("latbox").value=point.y;
document.getElementById("lonbox").value=point.x;
var marker = new GMarker(point,Icons[0]);
map.addOverlay(marker);

}

});


</script>



Regards
Manivannan.s
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 08-11-2007, 01:31 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: How to include Google earth in winforms of c# application

hi
i am trying to place my marker over google map based on my values(longitude,latitude) from database

have any idea to implement this?
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 08-11-2007, 01:43 AM
GDevakii GDevakii is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 138
GDevakii is on a distinguished road
Default Re: How to include Google earth in winforms of c# application

hi,
yes, we can implement it through XML, write the data's as XMl file and then
import the data's into Google map..

Regards
GDevaki
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 08-11-2007, 02:40 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: How to include Google earth in winforms of c# application

hi,
i have created xml file using my database data's
here is the sample
<markers>

<marker lat="43.91892" lng="-78.89231" html="Some stuff to display in the&lt;br&gt;Second Info Window" label="Marker Two" />
<marker lat="43.82589" lng="-79.10040" html="Some stuff to display in the&lt;br&gt;Third Info Window" label="Marker Three" />
</markers

how can i integrate my xml file to google map?
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 08-11-2007, 03:29 AM
smani smani is offline
D-Web Programmer
 
Join Date: Aug 2007
Posts: 56
smani is on a distinguished road
Default Re: How to include Google earth in winforms of c# application

hi,
i have attached the sample code, u can try this codings

content:
default4 contains aspx code
example contents ur XML data


Regards
Manivannan.S
Attached Files
File Type: txt Default4.txt (4.0 KB, 9 views)
File Type: txt example.txt (437 Bytes, 4 views)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 08-13-2007, 09:30 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: How to include Google earth in winforms of c# application

hi,
some issue with mapping:

There are several limitations to the Maps API:

* It doesn't provide a geocoding service; that is, you have to provide it with longitude and latitude. This means you need to rely on third-party geocoding tools to get longitude and latitude for an address.
* It doesn't include a routing or driving directions service.
* The Google Maps API key is restricted to generate maps only for URLs (website or a local host). You need to have a web server even for development.
* The key you receive is only valid for a single directory on your web site.
* It can be used for commercial purposes, but it should be available to end users for free.
* It can be used on a site that is password protected, but consumers should be able to sign up for a password without charge.
* Usage is not necessarily restricted, but if your site is getting more than 50,000 hits per day, you'd better contact Google.
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 08-14-2007, 11:42 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 246
H2o is on a distinguished road
Default Re: How to include Google earth in winforms of c# application

Hi Mani,


Is there any way to integrate any third party reporting tools to google map windows application for showing out some sort of statistical report?
__________________
H2O

Without us, no one can survive..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 08-14-2007, 11:45 AM
garunprasad garunprasad is offline
D-Web Trainee
 
Join Date: Mar 2007
Location: Chennai
Posts: 45
garunprasad is on a distinguished road
Send a message via ICQ to garunprasad Send a message via AIM to garunprasad Send a message via MSN to garunprasad Send a message via Yahoo to garunprasad Send a message via Skype™ to garunprasad
Smile Re: How to include Google earth in winforms of c# application

yes H2O,


I was also having the same query to be asked to Mani. But my second question was to show up 3D Modelling sort of reports.

I think Mani can answer to me as well.

Thanks in advance.
__________________
G.A.P
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 08-25-2007, 02:57 AM
GDevakii GDevakii is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 138
GDevakii is on a distinguished road
Question Re: How to include Google earth in winforms of c# application

hi,
I need to draw polygon and polyline over google map, is any idea?

Thanks
GDevaki
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #20 (permalink)  
Old 08-25-2007, 03:34 AM
smani smani is offline
D-Web Programmer
 
Join Date: Aug 2007
Posts: 56
smani is on a distinguished road
Default Re: How to include Google earth in winforms of c# application

Quote:
Originally Posted by GDevakii View Post
hi,
I need to draw polygon and polyline over google map, is any idea?

Thanks
GDevaki

hi,
here is the sample code to draw polygon,

// ***** Use SVG to draw and fill polygons

_mSvgEnabled = true;
_mSvgForced = true;

//Load map
var map = new GMap(document.getElementById("map"));

var lineThickness = 1;
var points2 = [];
var polygons = new Array();
map.setCenter(new GLatLng(47.6719664015333, -122.4019448761567), 6);//11);

getPoints();
Gpolygons = new GPolygon(points ,"#698b22", 2, 0.7,"#b3ee3a", 0.5) ;
map.addOverlay(Gpolygons) ;

function getPoints() {
points2.push(new GLatLng(47.67207767885599, -122.40447521209717));
points2.push(new GLatLng(47.67047381359744, -122.40391731262207));
points2.push(new GLatLng(47.67051716195521, -122.40129947662353));
points2.push(new GLatLng(47.67204878081891, -122.40127801895141));


}

use all other's necessary code from above post

Regards
Manivannan.s
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote