Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > <newbie> Using Google maps on ASP.NET 2.0 pages, how??

Reply
Thread Tools

<newbie> Using Google maps on ASP.NET 2.0 pages, how??

 
 
Jeff
Guest
Posts: n/a
 
      04-29-2007
Hey

I'm wondering how to use Google Maps on a ASP.NET 2.0 page?

I've read a few tutorials on this subject and I'm a bit confused. Some so it
is straight forward. Just put the google map code into the .aspx page and
run it - I have never been able to run it if I put some google map code
(javascript) directly into the .aspx file...

Some other articles I've read suggest creating a custom ASP.NET 2.0 server
control which works as a ASP.NET Google Map - And because it is a server
control, data can be bound to it.

For example this article http://dotnet.sys-con.com/read/171162.htm says
it'll describe how to create a Google Map control. I've read it I still
don't understand how to do it. The article shows lot of fancy screenshots of
the control, but it don't describe how to make the control... - or is it
something I've completely missunderstood...

Any suggestions??

Jeff



 
Reply With Quote
 
 
 
 
Michael Nemtsev
Guest
Posts: n/a
 
      04-29-2007
Hello jeff,

Discussed recently http://groups.google.com/group/micro...c16c5171cdf0fe

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

j> Hey
j>
j> I'm wondering how to use Google Maps on a ASP.NET 2.0 page?
j>
j> I've read a few tutorials on this subject and I'm a bit confused.
j> Some so it is straight forward. Just put the google map code into the
j> .aspx page and run it - I have never been able to run it if I put
j> some google map code (javascript) directly into the .aspx file...
j>
j> Some other articles I've read suggest creating a custom ASP.NET 2.0
j> server control which works as a ASP.NET Google Map - And because it
j> is a server control, data can be bound to it.
j>
j> For example this article http://dotnet.sys-con.com/read/171162.htm
j> says it'll describe how to create a Google Map control. I've read it
j> I still don't understand how to do it. The article shows lot of fancy
j> screenshots of the control, but it don't describe how to make the
j> control... - or is it something I've completely missunderstood...
j>
j> Any suggestions??
j>
j> Jeff
j>


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      04-30-2007
On Apr 29, 10:52 pm, "Jeff" <(E-Mail Removed)> wrote:
> Just put the google map code into the .aspx page and
> run it - I have never been able to run it if I put some google map code
> (javascript) directly into the .aspx file...
>


Yes, you just need to put a google maps code into an .aspx page. If it
doesn't work, give us an example of your code.

Note, you would need to have an API key.
http://www.google.com/apis/maps/signup.html

The interface to Google Maps is based on JavaScript, it means you have
to include a JavaScript from maps.google.com. You can build a control,
whatever, however it is not required for the solution to work.

 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      04-30-2007
Thanks for replying to my post, I really appreaciate it

Here is the markup of a simple .aspx page I created with google map... I
doesn't work!... It compiles, but no map are displayed. .. In the status
line of the browser, the text "error on page" appear for a few seconds
before it changes to "done"

Here is the source code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body onload="load()" onunload="GUnload()" >
<form id="form1" runat="server">
<div>
<script
src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAtil_7JSZXkq9 VTwQkvppgRTj87-E8mkBwalGLpuFeoa9XJoGVRRnp2bV6uZCXNFMgTSq91QjaeZ_5 w"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}
//]]>
</script>

</div>
</form>
</body>
</html>

any suggestions?

Jeff


 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      04-30-2007
On Apr 30, 9:03 pm, "Jeff" <(E-Mail Removed)> wrote:
> Thanks for replying to my post, I really appreaciate it
>
> Here is the markup of a simple .aspx page I created with google map... I
> doesn't work!... It compiles, but no map are displayed. .. In the status
> line of the browser, the text "error on page" appear for a few seconds
> before it changes to "done"
>



Hi Jeff,

regarding your code

1) It compiles/doesn't compiles - since you don't have any code-behind
it makes no sense
2) document.getElementById("map")) refers to an object named "map"

add a DIV with id="map" to your code,

for example

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

It will show you a map 400x400 using Google Maps API

 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      05-01-2007
The markup below works. I'm wondering if it is okay to use a google map like
I do below are should I make some changes to my code? for example put some
of the google map code to the code behind file, if that is possible?? and
lets say I have a database containing locations... how do I add those to the
map - Could it be done by having a method in the code behind file which
retrieve the locations from database and put them into the map?? and what
about when clicking inside the map, then I want that location clicked to be
stored in the database, how do I go about to that in asp.net 2.0??

I've created a simple test page based on php which are using ajax to save
data to the database etc.. but now I wants to learn how to the same using
ASP.NET 2.0

Any suggestions??


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body onload="load()" onunload="GUnload()" >
<form id="form1" runat="server">
<div>
<script
src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAtil_7JSZXkq9 VTwQkvppgRTj87-E8mkBwalGLpuFeoa9XJoGVRRnp2bV6uZCXNFMgTSq91QjaeZ_5 w"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}
//]]>
</script>
<div id="map" style="width: 500px; height: 300px"></div>
</div>
</form>
</body>
</html>


 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      05-01-2007
On May 1, 10:46 pm, "Jeff" <(E-Mail Removed)> wrote:
> for example put some
> of the google map code to the code behind file, if that is possible??


Once again: the Google Maps API is a javascript based. You can put a
google map code to the code behind file, but it should create the same
javascript code. That is

Response.Write(@"<script type="text/javascript">
//<![CDATA[....");

I don't know if it makes any sense.


> lets say I have a database containing locations... how do I add those to the
> map - Could it be done by having a method in the code behind file which
> retrieve the locations from database and put them into the map??


Acc. to the Google Maps API tutorial:
http://www.google.com/apis/maps/docu...ion/index.html

Using XML and Asynchronous HTTP with Maps

You can make a web form, a web service, etc. to return a XML that
contains a list of coordinates from database.


> and what
> about when clicking inside the map, then I want that location clicked to be
> stored in the database, how do I go about to that in asp.net 2.0??


It's all about Javascript and Google Maps API. There is nothing
related to ASP.net 2.0.

Acc. to the Google Maps API tutorial:
http://www.google.com/apis/maps/docu...ion/index.html

Click Handling

When a user clicks the map, API registers a "click" event. Using that
event you can create a javascript call of a server side function, e.g.
"savelocation.aspx?lat=xxxx&lng=yyyyy" where lat and lng came from
that "click" event.

Hope it helps

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Calendar and Google Maps ThaddaeusBrettAyers@gmail.com Computer Support 1 01-25-2008 11:22 PM
Looking for Google API expert to consult on our Google hosted apps(calendar, maps, email, docs) styles@xlsuite.com Ruby 0 11-20-2007 04:21 AM
MSN maps vs. Google maps Ralph Fox NZ Computing 0 07-30-2007 10:30 AM
google maps - alternative to google earth Martik Computer Support 9 01-12-2006 07:49 AM
bridging Google Earth and Google maps in script cybarber@gmail.com Java 2 11-28-2005 02:51 PM



Advertisments