Google Map widget

Oct 9, 2008 at 1:52 PM
Edited Oct 10, 2008 at 1:31 AM
Has anyone successfully created a Google Maps widget.  I did a cursory attempt at one and it only renders the very bottom portion of the map.  I would appreciate any help anyone can provide.  I am really after the functionality in the pageflakes page, but would settle for a map that at least completely renders in the widget container.

Here is my ASCX code:


@ Control Language="C#" AutoEventWireup="true" CodeFile="KMLMapWidget.ascx.cs" Inherits="Widgets_KMLMapWidget" %>
<asp:Panel ID="KMLMapContainer" runat="server">
<script src=;v=2&amp;key=ABQIAAAAUFMfUZPKMqdMWi3pHxiC-BT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQFOl8WGGoqC57LYJvl-o6kZlCk6A type="text/javascript"></script>
<div id="theMapDIV"></div>


Within my code behind's Page Load:


"var map; map = new GMap2(document.getElementById('theMapDIV'), G_NORMAL_MAP, 300, 300); map.setCenter(new GLatLng(37.4419, -122.1419), 13);",


As mentioned above, using this code it will render the Google Maps control within the widget, but it only shows the very bottom of the control.

Jan 22, 2009 at 7:42 AM
Hi futureshock2038,

Yes i've done .

First of all get the implementation of Shabdar Ghata on codeproject

1) put cGoogleMap.cs and GService in App_Code
2) put GoogleMapAPIWrapper.js in widgets directory
3) add two properties in UserProfile.cs in App_code : 


SettingsAllowAnonymousAttribute(true)]public virtual GoogleObject GoogleMapObject{get{return ((GoogleObject)(this.GetPropertyValue("GoogleMapObject")));}set{this.SetPropertyValue("GoogleMapObject", value);}}



SettingsAllowAnonymousAttribute(true)]public virtual GoogleObject GoogleMapObject_Old{get{return ((GoogleObject)(this.GetPropertyValue("GoogleMapObject_Old")));}set{this.SetPropertyValue("GoogleMapObject_Old", value);}}


3) modify the Web.Config as specified in Omar's Book to reference this Userprofile
4) transform the google ascx in google widget in widgets directory (get rid of updatepanel)


@ Control Language="C#" AutoEventWireup="true" CodeFile="GoogleMapWidget.ascx.cs" Inherits="Widgets_GoogleMapWidget" EnableViewState="false" %>



@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"Namespace="System.Web.UI" TagPrefix="asp" %>




<div id="GoogleMap_Div_Container">




div id="GoogleMap_Div" style="width:<%=GoogleMapObject.Width %>;height:<%=GoogleMapObject.Height %>;">




script src=";v=<%=GoogleMapObject.APIVersion %>&amp;key=<%=GoogleMapObject.APIKey %>" type="text/javascript"></script>




script type="text/javascript" src="GoogleMapAPIWrapper.js">





5) in google ascx.cs widget replace call to HttpContext.Current.Session by UserProfile.GoogleMapObject

6) in Gservice.cs replace call to HttpContext.Current.Session  by replace call to HttpContext.Current.Profile["GooglemapObject"]


Jan 27, 2009 at 3:55 AM
Thanks alot, I will definitely give this a try.

Oct 14, 2009 at 7:14 AM

anyone got this to work on the latest build?