Page 1 of 1

Google maps help

Posted: Sun Oct 09, 2011 6:03 am
by kodi
I want to use google maps in my site developed using visual studio(.net). I have found the code and learnt how to use it. Now I want to open the map in a new windows when a button is clicked. Since the google maps code is a javascript code I don't know how to use it with a button click (I am new to programming). I also want to pass two parameters from the database to use in coordinates of the map. what is the proper way to do this.

Re: Google maps help

Posted: Sun Oct 09, 2011 5:55 pm
by Neo
Though there are some guys who fetch Google map images from web for offline use, according to my memory it is illegal (Google only allows fetching their maps online). I came across a nice .Net cotrol written for Google Maps in CodeProject. I'm sure it will give you some help. Lat Lays Flat - Part 1 : A Google Maps .NET Control.

Re: Google maps help

Posted: Sun Oct 09, 2011 7:08 pm
by kodi
I'm not using them Offline. I'm using the code given by Google themselves. I just need to know how to open the map in a new window when a button click is performed.

Re: Google maps help

Posted: Sun Oct 09, 2011 10:26 pm
by Herath
Looks like you want to open a map in a new window. For this you will have to get familiarized with Google Maps API. It's easy.
Then you will need to add code to open up a new window and pass the coordinates to it as query strings or using any other method. I do not have ASP.NET installed to give it a try. The installer is giving an error. I will check if i could install it.

Re: Google maps help

Posted: Tue Oct 11, 2011 3:48 am
by Enigma
Hello
Try this sample. May help you out. Make sure to add your APIKEY to the script which is in the MapWindow.aspx
GoogleMapTest.zip
(132.28 KiB) Downloaded 436 times
Thanks

Re: Google maps help

Posted: Tue Oct 11, 2011 8:18 am
by kodi
The code I use don't ask for a API key. This is the code

Code: Select all

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
  html { height: 100% }
  body { height: 100%; margin: 0; padding: 0 }
  #map_canvas { height: 100% }
</style>
<script type="text/javascript"
    src="http://maps.googleapis.com/maps/api/js?sensor=true">
</script>
<script type="text/javascript">
    function initialize() {
       
        var myLat = 6.581481;
        var myLng = 79.96459;
        var latlng = new google.maps.LatLng(myLat,myLng);
        var myOptions = {
            zoom: 17,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP   
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
    }

</script>
</head>
<body onload="initialize()">
  <div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
Instead of hard coding the coordinates I want to pass them from a database. I can't call this javascript code from a button click in Visual Studio

Re: Google maps help

Posted: Tue Oct 11, 2011 12:04 pm
by Enigma
Hi
Made some alterations for the code. Try this.
GoogleMapTest(Edited).zip
(132.93 KiB) Downloaded 427 times

Re: Google maps help

Posted: Tue Oct 11, 2011 8:05 pm
by Herath
I also had time to do some modifications. Had little help from http://www.mikeborozdin.com/post/Workin ... SPNET.aspx
GoogleMapTest.rar
(122.12 KiB) Downloaded 436 times

Re: Google maps help

Posted: Wed Oct 12, 2011 4:07 am
by kodi
Thank a ton guys. This is exactly what I wanted :yahoo:
You guys were so helpful. Thanks again.