Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; GmaLine has a deprecated constructor in /home/pmwiki/pmwiki/cookbook/GoogleMapAPI/GoogleMapAPI.php on line 58

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; GmaMap has a deprecated constructor in /home/pmwiki/pmwiki/cookbook/GoogleMapAPI/GoogleMapAPI.php on line 107

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; GmaPoint has a deprecated constructor in /home/pmwiki/pmwiki/cookbook/GoogleMapAPI/GoogleMapAPI.php on line 164

Warning: Cannot modify header information - headers already sent by (output started at /home/pmwiki/pmwiki/cookbook/GoogleMapAPI/GoogleMapAPI.php:58) in /home/pmwiki/pmwiki/pmwiki.php on line 478

Warning: Cannot modify header information - headers already sent by (output started at /home/pmwiki/pmwiki/cookbook/GoogleMapAPI/GoogleMapAPI.php:58) in /home/pmwiki/pmwiki/pmwiki.php on line 1847
PmWiki | GoogleMapAPI / Multiple Site Keys
Recent Changes - Search:

PmWiki

pmwiki.org

Multiple Site Keys

Allow multiple domain name references to the same map.

  • Associative GmaKey patch (RussFink): Google binds your API key to your domain name, such that if you have multiple domains registered for your site, you need to have multiple API keys. In my case, I have www.finalscoretrivia.com and www.finalscoreohio.com pointing to the same set of pages. By default, the GmaKey contains only one key, and thus only one domain is "registered." The users using the unregistered domain to view the page won't see the map.

    I fixed this by making GmaKey an associative array. The following patch will do it (use the patch program. If you don't know what that is, perhaps the maintainer will upload a patched version.)
  • This can also be done more efficiently by putting the lookup code in the config.php. There is always an easier way. Just released pre4, which has a one-liner that does what you're looking for. BenWilson February 08, 2007, at 01:29 PM
 
--- gma-2.2.0-pre2.php.ORIG     Thu Feb  1 11:24:05 2007
+++ gma-2.2.0-pre2.php  Thu Feb  1 11:26:52 2007
@@ -212,11 +212,12 @@
 }
 function gmaAddressLookup($a) {
     global $GmaKey;
+    $_gmakey = $GmaKey[$_SERVER['HTTP_HOST']];
     $res = false;
     $url = sprintf(
             'http://maps.google.com/maps/geo?&q=%s&output=csv&key=%s',
             rawurlencode($a),
-            $GmaKey
+            $_gmakey
            );
     $coords = array();
     if($res = file_get_contents($url)) {
@@ -231,12 +232,13 @@
   global $GmaEnable, $GmaVersion, $GmaScript;
   global $GmaMaps, $GmaPoints, $GmaLines;
   global $GmaKey, $GmaDebugMsg, $GmaDefaults;
+  $_gmakey = $GmaKey[$_SERVER['HTTP_HOST']];

   GmaDoIEFix();
   $HTMLHeaderFmt[]
      =  '<style type=\'text/css\'>v:* { behavior:url(#default#VML); }</style>'
        ."\n<script src='http://maps.google.com/maps?file=api&v=2&key="
-       .$GmaKey."' type='text/javascript'></script>";
+       .$_gmakey."' type='text/javascript'></script>";
   $HTMLHeaderFmt[]
      =  "\n<script language='javascript' src='\$FarmPubDirUrl/scripts/gmaJs.js'
>"
        ."</script>\n";

Usage: in config.php, change $GmaKey = 'abcde...'; to $GmaKey['mydomain.com'] = 'abcde...';. NOTE, the patch above distinguishes between "www.mydomain.com" and "mydomain.com" but Google does not, so you need to copy the key from the first into the second (just use two lines of identical key)... Either that, or the maintainer can do the Php trickery to strip off the "www." portion and just use 'mydomain.com'.

  • Change Per Bram's suggestion, using a GMA link scrolls the web page to the top of the map.
    I hope you didn't use the code I send you.....

Status:Planned Version:2.2

Edit - History - Print - Recent Changes - Search
Page last modified on September 10, 2011, at 05:58 PM