Solved

asp.net google maps

Posted on 2010-08-20
3
572 Views
Last Modified: 2012-05-10
Hello experts

(1) I have latitude and longitude for every store saved in the database.
Example
storeID, storeName, latitude, longitude
100, ABC Store, 23.3323,236523
200, XYZ Store, 56.325,65.236

(2) I am passing storeID in url as query string to the locator page(locator.aspx)
Sample URL
http://www.myWebsite.com/locator.aspx?storeID=100

(3) On the page load method of locator.aspx page, I can query the database and get the latitude and longitude of the store.

In the page load method

string storeID = Request.QueryString["storeID"].ToString()
string latitude="";
string longitude="";

//Query the database with with storeID and get the latitude and longitude of the store.

I will have
latitude = 23.3323 and longitude=236523

I have a div tag on the aspx page
<div id="map_canvas" style="width:250px; height:250px"></div>

I want to show this latitude and longitude on the google map.

How do i do ?

Thanks




































0
Comment
Question by:neetu2008
  • 2
3 Comments
 
LVL 3

Expert Comment

by:gbarcalow
ID: 33486836
0
 
LVL 5

Assisted Solution

by:muhammadyasir
muhammadyasir earned 150 total points
ID: 33486866
Add a literal to your page and assign this in your page load like this.


Literal.Text ="<script type="text/javascript" src="http://www.google.com/jsapi?key=ABCDEFG"></script>
<script type="text/javascript">
  google.load("maps", "2.x");
   
  // Call this function when the page has been loaded
  var map = new google.maps.Map2(document.getElementById("map_canvas"));
  map.setCenter(new google.maps.LatLng("+Latitude+", "+Longitude+"), 13);   <=== Here is your lat long strings
    
</script>";

Open in new window

0
 
LVL 3

Accepted Solution

by:
gbarcalow earned 350 total points
ID: 33487028
Google gives you the info you need to embed a map, find the ll= tag and inject your long and lat.


Adding this code to any web page will give you a amp at long 47.128082 lat -122.21466

Easiesy way it to go to maps.google.com, find the zoom you want, click the link button then copy the 'Paste to HTML to embed in website' text. Also available is the 'Customize and preview embedded map' to change map size.
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/?ie=UTF8&amp;ll=47.128082,-122.214661&amp;spn=1.244538,1.83197&amp;t=h&amp;z=9&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/?ie=UTF8&amp;ll=47.128082,-122.214661&amp;spn=1.244538,1.83197&amp;t=h&amp;z=9&amp;source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question