{"id":109,"date":"2011-12-16T21:17:40","date_gmt":"2011-12-16T15:17:40","guid":{"rendered":"http:\/\/markwheeler.com\/wordpress\/?p=109"},"modified":"2011-12-16T21:17:40","modified_gmt":"2011-12-16T15:17:40","slug":"simple-google-map-from-sharepoint-list-using-jquery","status":"publish","type":"post","link":"https:\/\/markwheeler.com\/?p=109","title":{"rendered":"Simple Google Map from Sharepoint List using JQUERY"},"content":{"rendered":"<p>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.<\/p>\n<p>Adjust where applicable and paste onto your page.<\/p>\n<p>My Sharepoint list had two columns: City, State<\/p>\n<div id=\"_mcePaste\">\/\/ Call in the JQUERY Library<\/div>\n<div id=\"_mcePaste\">&lt;script src=&#8221;\/SiteAssets\/jquery-1.3.2.js&#8221;&gt;&lt;\/script&gt;<\/div>\n<div>\/\/ Image Placeholder<\/div>\n<div id=\"_mcePaste\">&lt;img id=&#8221;gmap&#8221; &gt;<\/div>\n<div>\/\/ The Script<\/div>\n<div id=\"_mcePaste\">&lt;script language = &#8220;javascript&#8221;&gt;<\/div>\n<div>\/\/ Base URL for Google Maps &#8211; You can change the size and set the markers to whatever you wish. Sensor=False is required.<\/div>\n<div>var URL = &#8216;https:\/\/maps.googleapis.com\/maps\/api\/staticmap?size=640&#215;480&amp;maptype=roadmap&amp;sensor=false&amp;markers=size:mid%7Ccolor:red&#8217;;<\/div>\n<div>\/\/ Here we build our SOAP packet that will make the call to the SP Lists webservices.<\/div>\n<div>function GetWhereData()<\/div>\n<div id=\"_mcePaste\">{<\/div>\n<div id=\"_mcePaste\">var soapPacket = &#8220;&lt;soapenv:Envelope xmlns:soapenv=&#8217;http:\/\/schemas.xmlsoap.org\/soap\/envelope\/&#8217;&gt; <\/div>\n<div id=\"_mcePaste\">&lt;soapenv:Body&gt; <\/div>\n<div id=\"_mcePaste\">&lt;GetListItems xmlns=&#8217;http:\/\/schemas.microsoft.com\/sharepoint\/soap\/&#8217;&gt; <\/div>\n<div id=\"_mcePaste\">&lt;listName&gt;Locator&lt;\/listName&gt; <\/div>\n<div id=\"_mcePaste\">&lt;viewFields&gt; <\/div>\n<div id=\"_mcePaste\">&lt;ViewFields&gt; <\/div>\n<div>\/\/ Call in your location fields<\/div>\n<div id=\"_mcePaste\">&lt;FieldRef Name=&#8217;Title&#8217; \/&gt; <\/div>\n<div id=\"_mcePaste\">&lt;FieldRef Name=&#8217;City&#8217; \/&gt; <\/div>\n<div id=\"_mcePaste\">&lt;FieldRef Name=&#8217;State&#8217; \/&gt; <\/div>\n<div id=\"_mcePaste\">&lt;\/ViewFields&gt; <\/div>\n<div id=\"_mcePaste\">&lt;\/viewFields&gt; <\/div>\n<div id=\"_mcePaste\">&lt;\/GetListItems&gt; <\/div>\n<div id=\"_mcePaste\">&lt;\/soapenv:Body&gt; <\/div>\n<div id=\"_mcePaste\">&lt;\/soapenv:Envelope&gt;&#8221;;<\/div>\n<div id=\"_mcePaste\">jQuery.ajax({<\/div>\n<div>\/\/ Change this path as applicable<\/div>\n<div>url: &#8220;\/_vti_bin\/lists.asmx&#8221;,<\/div>\n<div id=\"_mcePaste\">type: &#8220;POST&#8221;,<\/div>\n<div id=\"_mcePaste\">dataType: &#8220;xml&#8221;,<\/div>\n<div id=\"_mcePaste\">data: soapPacket,<\/div>\n<div id=\"_mcePaste\">complete: processResult,<\/div>\n<div id=\"_mcePaste\">contentType: &#8220;text\/xml; charset=&#8221;utf-8&#8243;&#8221;<\/div>\n<div id=\"_mcePaste\">});<\/div>\n<div id=\"_mcePaste\">}<\/div>\n<div id=\"_mcePaste\">function processResult(xData, status) {<\/div>\n<div id=\"_mcePaste\">jQuery(xData.responseXML).find(&#8220;z\\:row&#8221;).each(function() {<\/div>\n<div>\/\/ For Each Row in your List grab the City and State then append it to the base URL variable<\/div>\n<div>URL += &#8220;%7C&#8221; + $(this).attr(&#8220;ows_City&#8221;) + &#8220;,&#8221; + $(this).attr(&#8220;ows_State&#8221;);<\/div>\n<div id=\"_mcePaste\">});<\/div>\n<div id=\"_mcePaste\">\/\/alert(URL); &lt;&#8212; For Testing<\/div>\n<div>\/\/ Set the IMG SRC to your Base URL plus location data<\/div>\n<div id=\"_mcePaste\">$(&#8216;#gmap&#8217;).attr(&#8216;src&#8217;, URL);<\/div>\n<div id=\"_mcePaste\">}<\/div>\n<div>\/\/ Let&#8217;s wait until the Document is loaded before we do anything.<\/div>\n<div id=\"_mcePaste\">$(document).ready( function(){<\/div>\n<div id=\"_mcePaste\">GetWhereData();<\/div>\n<div id=\"_mcePaste\">});<\/div>\n<div id=\"_mcePaste\">&lt;\/script&gt;<\/div>\n<div>And that&#8217;s pretty much it. It&#8217;s a static map, so there&#8217;s no scroll or zoom. Saving that for another day.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2,10,11],"tags":[49,62,99],"class_list":["post-109","post","type-post","status-publish","format-standard","hentry","category-computer","category-sharepoint","category-software","tag-google-maps","tag-jquery","tag-sharepoint-2010"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=109"}],"version-history":[{"count":0,"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/109\/revisions"}],"wp:attachment":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}