Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 604
  • Last Modified:

asp.net google maps

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
neetu2008
Asked:
neetu2008
  • 2
2 Solutions
 
muhammadyasirCommented:
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
 
gbarcalowCommented:
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now