473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to give longitude and latitude from our database to google map function

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3.  
  4. function initialize() 
  5. {
  6.  
  7.     alert(asd);
  8. var myLatlng = new google.maps.LatLng(26.211954,50.607727);
  9.  
  10. var myOptions = {
  11. zoom: 4,
  12. center: myLatlng,
  13.  
  14. mapTypeId: google.maps.MapTypeId.ROADMAP
  15. }
  16. var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  17.  
  18. var marker = new google.maps.Marker({
  19. position: myLatlng,
  20. map: map,
  21. title:"Windsor Tower Hotel "
  22. });
  23. var infowindow = new google.maps.InfoWindow({  
  24.   content: Jnantoures
  25. }); 
  26. infowindow.open(map, marker);  
  27. }
  28. </script>
This is a google map function created by javascript here longitude and latitude directly give the function .But i want the longitude and latitude is given from our database to this function. How to do it? my project is asp.net( useing vb),database is sql server pls rply
Sep 15 '11 #1
3 4864
Frinavale
9,735 Expert Mod 8TB
There's a lot of ways to do this.

But I think the best way would be to write the database value into the script using the ASP Response.Write() method.

First you need to define a variable (or variables) that is either Protected or Public in your Page's Code-Behind. Then you need to fill this variable (or variables) with data retrieved from your database.

After you've done that, switch over to your ASP.NET Design-Code, go to the place where your JavaScript is defined call the Response.Write(variableName) method to write the value of the variable(s) into the page.

Recall that anything between <% %> is server-side code that is called in order to render something at a particular place in your web page.

So, if you have two Public variable called latitudeServerSideVariable and longitudeServerSideVariable in your Page's Code-Behind that you fill with data from your database (say on your Page Load event)...You would then put the following in your JavaScript method to write their values into the script:
Expand|Select|Wrap|Line Numbers
  1. function initialize() 
  2. {
  3.  var lat = <%Response.Write(latitudeServerSideVariable);%>
  4.  var long = <%Response.Write(longitudeServerSideVariable);%>
  5.   ....
  6. }
Another, shorthand way to call the Response.Write method is to use <%=. So another way to accomplish the same thing as my above posted code would be to have:
Expand|Select|Wrap|Line Numbers
  1. function initialize() 
  2. {
  3.  var lat = <%=latitudeServerSideVariable%>
  4.  var long = <%=longitudeServerSideVariable"%>
  5.   ....
  6. }
-Frinny
Sep 15 '11 #2
how to fill this variable (or variables) with data retrieved from our database.
Sep 16 '11 #3
Frinavale
9,735 Expert Mod 8TB
Please read the quick article about how to use a database in your program

-Frinny
Sep 16 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: jack | last post by:
not sure exactly where I should ask this question, but im looking for a database of Australian Postcodes that included the longitude/latitude. Does anyone know of such a thing? Preferably...
2
by: Steven Burn | last post by:
..:: The Specs: MS Access 2000 (host charges extra for SQL/MySQL) MS Windows Server 2003 (prod) / MS XP SP1 (dev) ..:: The setup: The database has been setup with two tables; tblDownloads
2
by: mattmerc | last post by:
Hi all, I've searched around on this topic but haven't come up with anything that matches exactly what I am trying to do. I have an ASP .net application running over a SQL database. I need to...
7
by: changs | last post by:
Hi, all I have a asm code, I suspect it sort of socket programming. Can anyone here give some instructions on how to determine the function or give the psudo-code in C? Thanks in advance! ...
7
by: momo | last post by:
Hello to all, I need some help. I am looking for a database connection function that I can use in my ASP.NET site. This would be in VB.NET. What I want to be able to do is call the function and...
4
by: lligogogo | last post by:
Hi, I am new on java function. I created a FORM in asp page, the FORM have three switch. When user selects UPDATE, first thing have to validate is check if this user id is in the control table or...
5
by: arial | last post by:
Hi all, I have a sql .bak file which i need to convert into xml file. can someone help with this? pointing out to some tutorial or some suggetion on how to start? Thak you,
1
by: alan5 | last post by:
I want to answer on the topic australian postcode db with longitude/latitude posted by jack. He wrote: not sure exactly where I should ask this question, but im looking for a database of...
2
amarniit
by: amarniit | last post by:
ABC Bank operates a number of branches and a customer of the bank can have any number of accounts which may be a joint account allowing more than one customer to operate a given account. The bank...
1
by: Lucas Gordon | last post by:
Hi there, I'm busy making a site that displays markers and info from an xml file on a map. I'm at the point where all markers stored in the xml file are displayed on the map, but I only want certain...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.