Mapping is is excellent in its use of Google Maps api and open layers, however I really need to be able to use muliple api keys for google maps. My system is used in 2 ways, one from the internet and is known as http://www.mydomain.com/cms which requires a google api map key set for that domain, mydomain.com and secondly it is used from inside the government firewall and is known as http://myhost/cms for which I have the other api key from google keyed to myhost.

The problem is no matter how I configure mapping kit, some of my users are faced with the annoying message

The Google Maps API Key used on this website was registered for a different website......

Is there any way we can work on getting multiple api keys into mapping kit and having it match the current url to determine which key? I built other mapping systems coding this logic into the php but I really dont know how to patch a drupal module and I am not a drupal developer yet.

What do you say John, do you have any time to work on this?
Thanks
Franco

Comments

jpulles’s picture

Franco,

I don't think it's necessary to change the mapping kit for this. You can override specific entries in the variable table using the settings.php files for your sites. Just enter something like

$conf = array(
'google_maps_key' => '<google maps key for this site>'
);

to override the google maps key in the database. Although I didn't check this, it should work.

Regards,
John

jpulles’s picture

Status: Active » Closed (fixed)

Assuming the previous hint solves this 'problem' ...

spydmobile’s picture

Well thanks for the suggestion, but no, it does not, I have only one site, and that is one settings.php file and have two domains on the same site, those two domains both need their own key. What I may do is try and set up a rule that when a user logs in, it checks what domain they came in from and override the variable holding the google map key and force it to the one associated with the domain.

If you were to add this feature to mapping kit, I envisioned changing the variable to an array, holding domains and keys. At any rate, thanks for looking at it!
Franco

jpulles’s picture

If you have one site which can be reached using different domains, you can use different settings files for each domain; but since it is the same site, the same db_url should be used.

You may want to set the google map variable in settings.php depending on the value of $_SERVER['HTTP_HOST']:

$my_google_map_keys = array('host1' => 'key1', 'host2' => 'key2');

$conf = array(
  'google_maps_key' => $my_google_map_keys[$_SERVER['HTTP_HOST']]
);

Hope this helps you.

newtoid’s picture

This works great!

we have two domains pointing at the same site, just need to make sure there are no other keys specified elsewhere (mykml, cck_map etc)