{"id":95,"date":"2008-09-19T14:20:10","date_gmt":"2008-09-19T14:20:10","guid":{"rendered":"http:\/\/www.myfatblog.co.uk\/?p=95"},"modified":"2008-09-19T14:52:18","modified_gmt":"2008-09-19T14:52:18","slug":"using-google-map-api-keys-with-alternate-access-mapping","status":"publish","type":"post","link":"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/09\/using-google-map-api-keys-with-alternate-access-mapping\/","title":{"rendered":"Using Google Map API keys with Alternate Access Mapping."},"content":{"rendered":"<p>On a clients Intranet\/Extranet recently, I was asked to provide a static Google map for both staff and visitors to find the Head Office location.<\/p>\n<p>The main problem with this is that Google want you to use a static API key for each URL that will refer a connection. Obviously if you&#8217;re using alternate access mapping then this will be a problem as internal staff may be connecting to http:\/\/intranet whilst your customers may be using http:\/\/extranet.myhouse.com<\/p>\n<p>The simplest way that i could see of fixing this problem is to use Javascript in a content editor webpart to look at the Document.URL and output the correct IMG tag accordingly. I also wanted to ensure that it wouldn&#8217;t matter if we had a port in the URL, so I&#8217;ve stripped that as well.<\/p>\n<p>Here&#8217;s the code.<\/p>\n<pre lang=\"javascript\" line=\"1\">\r\n<script type=\"text\/javascript\" language=\"javascript\">\r\nvar myRequest = document.URL.toUpperCase();\r\n\r\nvar firstBound = myRequest.indexOf(\"HTTP:\/\/\")+ 7;\r\n\r\nvar secondBound = myRequest.indexOf('\/',firstBound);\r\n\r\nvar serverUrl = myRequest.substring(firstBound,secondBound);\r\n\r\n\/\/Now check for a port entry.\r\nif (serverUrl.indexOf(':') == -1)\r\n{\r\n\/\/There isn't a port so we're ok.\r\n}\r\nelse\r\n{\r\n\/\/We've got a port entry to remove.\r\nserverUrl = serverUrl.substring(0,serverUrl.indexOf(':'));\r\n}\r\nif (serverUrl == \"{INTERNALURL HERE in UPPERCASE\")\r\n{\r\ndocument.writeln(\"<div class=\"bs-BoxBorder\" style=\"text-align: center;\">\");\r\ndocument.writeln(\"<img decoding=\"async\" src=\"http:\/\/maps.google.com\/staticmap?center=51.504235,-0.081904&#038;zoom=15&#038;size=400x400&#038;markers=51.504035,-0.081890,blueb&#038;key={Your Google API Key goes Here}\"><\/div>\");\r\n\r\n}\r\nelse if (serverUrl == \"{EXTERNALURL HERE  in UPPERCASE}\")\r\n{\r\ndocument.writeln(\"<div class=\"bs-BoxBorder\" style=\"text-align: center;\">\");\r\ndocument.writeln(\"<img decoding=\"async\" src=\"http:\/\/maps.google.com\/staticmap?center=51.504235,-0.081904&#038;zoom=15&#038;size=400x400&#038;markers=51.504035,-0.081890,blueb&#038;key={Your Google API Key goes Here}\"><\/div>\");\r\n\r\n\r\n}\r\n\r\n<\/script>\r\n<\/pre>\n<p>EDIT: Ok, I&#8217;m really not happy with the way this code plugin is formatting pasted scripts.. they look fine in the editor but awful on the site. I&#8217;ll leave this one as is for now and hopefully sort out a better code display block asap. EDITEDIT Much better.. I changed to the WP-Syntax plugin which seems to work.<\/p>\n<p>Reg.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On a clients Intranet\/Extranet recently, I was asked to provide a static Google map for both staff and visitors to find the Head Office location. The main problem with this is that Google want you to use a static API key for each URL that will refer a connection. Obviously if you&#8217;re using alternate access &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/09\/using-google-map-api-keys-with-alternate-access-mapping\/\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[13,16,8],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using Google Map API keys with Alternate Access Mapping. - Blog of an overweight SharePoint addict<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/09\/using-google-map-api-keys-with-alternate-access-mapping\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Google Map API keys with Alternate Access Mapping. - Blog of an overweight SharePoint addict\" \/>\n<meta property=\"og:description\" content=\"On a clients Intranet\/Extranet recently, I was asked to provide a static Google map for both staff and visitors to find the Head Office location. The main problem with this is that Google want you to use a static API key for each URL that will refer a connection. Obviously if you&#8217;re using alternate access &hellip; Continue reading\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/09\/using-google-map-api-keys-with-alternate-access-mapping\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog of an overweight SharePoint addict\" \/>\n<meta property=\"article:published_time\" content=\"2008-09-19T14:20:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2008-09-19T14:52:18+00:00\" \/>\n<meta name=\"author\" content=\"Cimares\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cimares\" \/>\n<meta name=\"twitter:site\" content=\"@cimares\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Cimares\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/09\/using-google-map-api-keys-with-alternate-access-mapping\/\",\"url\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/09\/using-google-map-api-keys-with-alternate-access-mapping\/\",\"name\":\"Using Google Map API keys with Alternate Access Mapping. - Blog of an overweight SharePoint addict\",\"isPartOf\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/#website\"},\"datePublished\":\"2008-09-19T14:20:10+00:00\",\"dateModified\":\"2008-09-19T14:52:18+00:00\",\"author\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/09\/using-google-map-api-keys-with-alternate-access-mapping\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#website\",\"url\":\"http:\/\/www.myfatblog.co.uk\/\",\"name\":\"Blog of an overweight SharePoint addict\",\"description\":\"The rantings of a (not so) food obsessed IT consultant!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.myfatblog.co.uk\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6\",\"name\":\"Cimares\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg\",\"contentUrl\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg\",\"caption\":\"Cimares\"},\"sameAs\":[\"http:\/\/www.myfatblog.co.uk\"],\"url\":\"http:\/\/www.myfatblog.co.uk\/index.php\/author\/reginald\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Google Map API keys with Alternate Access Mapping. - Blog of an overweight SharePoint addict","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/09\/using-google-map-api-keys-with-alternate-access-mapping\/","og_locale":"en_US","og_type":"article","og_title":"Using Google Map API keys with Alternate Access Mapping. - Blog of an overweight SharePoint addict","og_description":"On a clients Intranet\/Extranet recently, I was asked to provide a static Google map for both staff and visitors to find the Head Office location. The main problem with this is that Google want you to use a static API key for each URL that will refer a connection. Obviously if you&#8217;re using alternate access &hellip; Continue reading","og_url":"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/09\/using-google-map-api-keys-with-alternate-access-mapping\/","og_site_name":"Blog of an overweight SharePoint addict","article_published_time":"2008-09-19T14:20:10+00:00","article_modified_time":"2008-09-19T14:52:18+00:00","author":"Cimares","twitter_card":"summary_large_image","twitter_creator":"@cimares","twitter_site":"@cimares","twitter_misc":{"Written by":"Cimares","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/09\/using-google-map-api-keys-with-alternate-access-mapping\/","url":"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/09\/using-google-map-api-keys-with-alternate-access-mapping\/","name":"Using Google Map API keys with Alternate Access Mapping. - Blog of an overweight SharePoint addict","isPartOf":{"@id":"http:\/\/www.myfatblog.co.uk\/#website"},"datePublished":"2008-09-19T14:20:10+00:00","dateModified":"2008-09-19T14:52:18+00:00","author":{"@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.myfatblog.co.uk\/index.php\/2008\/09\/using-google-map-api-keys-with-alternate-access-mapping\/"]}]},{"@type":"WebSite","@id":"http:\/\/www.myfatblog.co.uk\/#website","url":"http:\/\/www.myfatblog.co.uk\/","name":"Blog of an overweight SharePoint addict","description":"The rantings of a (not so) food obsessed IT consultant!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.myfatblog.co.uk\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6","name":"Cimares","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/image\/","url":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg","contentUrl":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg","caption":"Cimares"},"sameAs":["http:\/\/www.myfatblog.co.uk"],"url":"http:\/\/www.myfatblog.co.uk\/index.php\/author\/reginald\/"}]}},"_links":{"self":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/95"}],"collection":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":0,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}