Solved

asp.net google maps

Posted on 2010-08-20
3
546 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
Comment Utility
0
 
LVL 5

Assisted Solution

by:muhammadyasir
muhammadyasir earned 150 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now