Public Function maptest()
As String
Dim strmap
As String =
""
' Dim strMap As String = ""
Dim strMap1
As String =
""
Dim drResult
As SqlDataReader
Dim SQLResult
As String =
""
Dim strLon
As String =
""
Dim strLat
As String =
""
Try
strmap = strmap +
" <!DOCTYPE html PUBLIC """"-//W3C//DTD XHTML 1.0 Strict//EN"""" """"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">"
strmap = strmap +
" <html xmlns=""http://www.w3.org/1999/xhtml"">"
strmap = strmap +
" <head>"
strmap = strmap +
" <meta http-equiv=""content-type"" content=""google maps via ASP.Net : text/html; charset=utf-8""/>"
strmap = strmap +
" <title>Google Maps JavaScript API Example</title>"
True
End If
If Not IsDBNull(drResult("lon"))
Then
strLon = drResult("lon").ToString
End If
If Not IsDBNull(drResult("lat"))
Then
strLat = drResult("lat").ToString
End If
strmap = strmap +
"var point = new GLatLng(" & drResult("lat").ToString &
"," & drResult("lon").ToString &
");"
strmap = strmap +
" var marker = createMarker(point,'" & drResult("lat").ToString &
"');"
antonyvijaya...
Member
44 Points
50 Posts
Google Maps via ASP.NET / SQL Server Tutorial
Jul 08, 2008 10:53 AM|LINK
Hi,
I worked out for google map with ASP.Net / VB.Net. below steps you have to follow,
1. You need to get encrpyted key from google which key for your own website.
2. create a table as below,
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[map]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[map]
GO
CREATE TABLE [dbo].[map] (
[id] [numeric](18, 0) IDENTITY (1, 1) NOT NULL ,
[lat] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[lon] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[description] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[cid] [numeric](18, 0) NOT NULL ---cid meant centerID
) ON [PRIMARY]
GO
3. Copy below code for map_test.aspx page
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Map_test.aspx.vb" Inherits="Map_test" %><% Response.Write(maptest())%>
4. Below code for map_test.aspx.vb
Public Function maptest() As String Dim strmap As String = "" ' Dim strMap As String = "" Dim strMap1 As String = "" Dim drResult As SqlDataReader Dim SQLResult As String = "" Dim strLon As String = "" Dim strLat As String = "" Trystrmap = strmap +
" <!DOCTYPE html PUBLIC """"-//W3C//DTD XHTML 1.0 Strict//EN"""" """"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">"strmap = strmap +
" <html xmlns=""http://www.w3.org/1999/xhtml"">"strmap = strmap +
" <head>"strmap = strmap +
" <meta http-equiv=""content-type"" content=""google maps via ASP.Net : text/html; charset=utf-8""/>"strmap = strmap +
" <title>Google Maps JavaScript API Example</title>"strmap = strmap +
" <script src=""http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAXu6-xqCzQg7UF16n1xbPlxRy0V4Q1dfyNo3tEYtAttAGexdRsBSFtycVVZx_tF4NT4Xrn_SOyBa6pQ"""strmap = strmap +
" type=""text/javascript""></script>"strmap = strmap +
" <script type=""text/javascript"">" 'strmap = strmap + " //<![CDATA[" 'strmap = strmap + " // Creates a marker whose info window displays the given number"strmap = strmap +
" function createMarker(point, number)"strmap = strmap +
" {"strmap = strmap +
" var marker = new GMarker(point);" 'strmap = strmap + " // Show this markers index in the info window when it is clicked"strmap = strmap +
" var html = number;"strmap = strmap +
" GEvent.addListener(marker, ""click"", function() {marker.openInfoWindowHtml(html);});"strmap = strmap +
" return marker;"strmap = strmap +
" };"strmap = strmap +
" function load() {"strmap = strmap +
" if (GBrowserIsCompatible()) {"strmap = strmap +
" var map = new GMap2(document.getElementById(""map""));"strmap = strmap +
" map.addControl(new GLargeMapControl());"strmap = strmap +
" map.addControl(new GMapTypeControl());"strmap = strmap +
" map.addControl(new GScaleControl());" Dim blnPoint As Boolean = FalseclsSearch.ConnectionString() ' calling connectionstring function
SQLResult =
"Select * from map where cid=12" ' i just hard code for center id.drResult = SqlHelper.ExecuteReader(clsSearch.t_IncidentStr, CommandType.Text, SQLResult) ' executing sql query by using sql helper class
If drResult.HasRows Then While drResult.Read If blnPoint = False Thenstrmap = strmap +
" map.setCenter(new GLatLng(" & drResult("lat").ToString & "," & drResult("lon").ToString & "), 13);"blnPoint =
True End If If Not IsDBNull(drResult("lon")) Then strLon = drResult("lon").ToString End If If Not IsDBNull(drResult("lat")) Then strLat = drResult("lat").ToString End Ifstrmap = strmap +
"var point = new GLatLng(" & drResult("lat").ToString & "," & drResult("lon").ToString & ");"strmap = strmap +
" var marker = createMarker(point,'" & drResult("lat").ToString & "');"strmap = strmap +
"map.addOverlay(marker);" End While End Ifstrmap = strmap +
" }"strmap = strmap +
" }" ' strmap = strmap + " //]]>"strmap = strmap +
" </script>"strmap = strmap +
" </head>"strmap = strmap +
" <body onload=""load()"" onunload=""GUnload()"">"strmap = strmap +
" <div id=""map"" style=""width: 1200px; height: 600px""></div>"strmap = strmap +
" </body>"strmap = strmap +
" </html>" Catch ex As Exception End Try Return strmap End FunctionPlease free to ask your queries and if this code is useful for you, kindly post response.
thank you.
Ajax xml-script Tabstrip Code sample Code sample sql script countries country province Provinces server 2000 SQL ADO.Net Access Database email ASP.NET ASP.NET AJAX ASP.NET TextBox Javascript MultiLine MaxLength asp.NET 1.1 .Net FAQ Links daily Free Code asp.NET 2.0 c# asp asp .net ... c# ... SQL Asp .net .NET applet .net .Net Faqs .NET Answers .NET Interview Question .net interview faqs User control aspose.newsletter Abstract class class structure code snippets FAQ .net layered design
prah.NET
Participant
758 Points
126 Posts
Re: Google Maps via ASP.NET / SQL Server Tutorial
Jul 08, 2008 11:34 AM|LINK
hi
i think you should write it as an article or blog...
in that way more people could get advantage of your work
thanks and regards
prahlad
antonyvijaya...
Member
44 Points
50 Posts
Re: Google Maps via ASP.NET / SQL Server Tutorial
Jul 08, 2008 04:54 PM|LINK
Hi,
Thanks for suggestion.
Regards,
Vijayan.
cherukuriksb...
Member
6 Points
7 Posts
Re: Google Maps via ASP.NET / SQL Server Tutorial
Jul 23, 2008 01:02 PM|LINK
Hi vijayan
Tell me how to get Encrypted key for our website from google.....
And describe the what the Map table contains and their colums..I am unable to know about that
Thanks In Adv :)
antonyvijaya...
Member
44 Points
50 Posts
Re: Google Maps via ASP.NET / SQL Server Tutorial
Jul 24, 2008 11:23 AM|LINK
You can get the encrypted key from http://www.google.com/local/add/lookup?hl=en-US&gl=US
you will get unique key for the google map.
the table which i given the post is enough for the map. just copy and paste to create the table.
if it is useful information , pls mark it as ANSWER.
thanks.
cherukuriksb...
Member
6 Points
7 Posts
Re: Google Maps via ASP.NET / SQL Server Tutorial
Jul 24, 2008 11:40 AM|LINK
My queries
How to fill that Table??
What does lat,lon,Cid Stands for ??
Always DataReader gives empty because there are no rows in Table
How to give a particular locations to find ?? like giving input
I ran your code but i got blank map image with out location :( and some java script error when we are dragging
Please help me in this issue
antonyvijaya...
Member
44 Points
50 Posts
Re: Google Maps via ASP.NET / SQL Server Tutorial
Jul 25, 2008 06:09 AM|LINK
How to fill that Table??
get the location's longitude and latitude for your place(where you want to point it out n the map) from web
What does lat,lon,Cid Stands for ??
CID which is primary key( not neccessary, it depends on ur requirements)
lat - latitude ( which latitude for your place)
lon- longitude
Always DataReader gives empty because there are no rows in Table
Please post ur code
How to give a particular locations to find ?? like giving input
find the longitude and latitude of the locations from the web ( example : http://jan.ucc.nau.edu/~cvm/latlon_find_location.html )
Good Luck.
cherukuriksb...
Member
6 Points
7 Posts
Re: Google Maps via ASP.NET / SQL Server Tutorial
Jul 25, 2008 06:32 AM|LINK
Hi
Vijayan
Thanks a lot for ur help
I jst copied ur code. but its giving one error " We are sorry ,But we dont have maps at this zoom level .Please look broader level"
How to give zoom level ?? Where are giving that in your code??
I instered in Map Table as for ex Hongkong city lat as 22 15 N lat as 114 10 E .. is this fine or any changes??
Thanks
antonyvijaya...
Member
44 Points
50 Posts
Re: Google Maps via ASP.NET / SQL Server Tutorial
Jul 25, 2008 07:12 AM|LINK
You must use 22 15N as 22.15 in the coordinates n the table.
mail me antonyvijayan@gmail.com or i m online.
Gud luck
venkatu2005
All-Star
32487 Points
6742 Posts
Re: Google Maps via ASP.NET / SQL Server Tutorial
Sep 10, 2008 06:53 AM|LINK
Hai
I got error on
clsSearch , CommandType not declared
let me know...
actually wat it shows..
wat is the use of creating table .
how you store the data...
let me know in detail...
Thanks.