Interactive Google Map Web Part for Sharepoint 2010

 Computer, Sharepoint, Software  Comments Off on Interactive Google Map Web Part for Sharepoint 2010
Dec 202011
 
Share

I needed a way to display an interactive Google Map against a Sharepoint list over SSL. I did a slight modification to Mazin’s great Google Map Web Part on Codeplex.

In MapWebPart.cs – Look for ResolveAddress function and add the following line at the top of function.

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

Change the String.Format to HTTPS instead of HTTP.

Add System.Net to the References. Build and Deploy.

Here’s the link to my modified source. the .WSP is in the /bin/release folder.

And the obligatory keywords to make this solution “google-able”:  .Net C# WebClient DownloadString XMLDocument.XML https://maps.googleapis.com/maps/api Google Maps Web Part

Simple Google Map from Sharepoint List using JQUERY

 Computer, Sharepoint, Software  Comments Off on Simple Google Map from Sharepoint List using JQUERY
Dec 162011
 
Share

I created a simply JQUERY script to allow you to query location data from a basic Sharepoint list and then plot that data on a static Google Map.

Adjust where applicable and paste onto your page.

My Sharepoint list had two columns: City, State

// Call in the JQUERY Library
<script src=”/SiteAssets/jquery-1.3.2.js”></script>
// Image Placeholder
<img id=”gmap” >
// The Script
<script language = “javascript”>
// Base URL for Google Maps – You can change the size and set the markers to whatever you wish. Sensor=False is required.
var URL = ‘https://maps.googleapis.com/maps/api/staticmap?size=640×480&maptype=roadmap&sensor=false&markers=size:mid%7Ccolor:red’;
// Here we build our SOAP packet that will make the call to the SP Lists webservices.
function GetWhereData()
{
var soapPacket = “<soapenv:Envelope xmlns:soapenv=’http://schemas.xmlsoap.org/soap/envelope/’>
<soapenv:Body>
<GetListItems xmlns=’http://schemas.microsoft.com/sharepoint/soap/’>
<listName>Locator</listName>
<viewFields>
<ViewFields>
// Call in your location fields
<FieldRef Name=’Title’ />
<FieldRef Name=’City’ />
<FieldRef Name=’State’ />
</ViewFields>
</viewFields>
</GetListItems>
</soapenv:Body>
</soapenv:Envelope>”;
jQuery.ajax({
// Change this path as applicable
url: “/_vti_bin/lists.asmx”,
type: “POST”,
dataType: “xml”,
data: soapPacket,
complete: processResult,
contentType: “text/xml; charset=”utf-8″”
});
}
function processResult(xData, status) {
jQuery(xData.responseXML).find(“z\:row”).each(function() {
// For Each Row in your List grab the City and State then append it to the base URL variable
URL += “%7C” + $(this).attr(“ows_City”) + “,” + $(this).attr(“ows_State”);
});
//alert(URL); <— For Testing
// Set the IMG SRC to your Base URL plus location data
$(‘#gmap’).attr(‘src’, URL);
}
// Let’s wait until the Document is loaded before we do anything.
$(document).ready( function(){
GetWhereData();
});
</script>
And that’s pretty much it. It’s a static map, so there’s no scroll or zoom. Saving that for another day.