Monthly Archives: February 2012

ASP.NET – show location using postal code on Google Map

<asp:Content ID="Content2" ContentPlaceHolderID="HeadPlaceHolder" Runat="Server">    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=YourKey" type="text/javascript"></script>    <script type="text/javascript">        var geocoder;        var map;        function initialize() {            map = new google.maps.Map(document.getElementById("googleMap"));            geocoder = new GClientGeocoder();        }       function codeAddress(address) {           if (geocoder) {               geocoder.getLatLng(                        address,                        function (point) {                            if (!point) {                                console.log(address + " not found");                            }                            else {                                map.setCenter(point, 15);                                var marker = new GMarker(point, { draggable: false });                                map.addOverlay(marker);                                GEvent.addListener(marker, "dragend", function () {                                    marker.openInfoWindowHtml("<h2>Event name here</h2>");                                });                                GEvent.addListener(marker, "click", function () {                                    marker.openInfoWindowHtml("<h2>Event name here</h2>");                                });                                GEvent.trigger(marker, "click");                            }                        }                    );           }      }       $(document).ready(function () {           initialize();           codeAddress("<%= EventLocation %>,Canada");       });    </script></asp:Content><asp:Content ID="Content1" ContentPlaceHolderID="InteriorContent" Runat="Server">    <h1>Additional Information</h1>    <br />    <p>Event Location:</p>    <div class="googleMapWrapper">        <div id="googleMap" style="width:530px; height:291px"></div>    </div></asp:Content>