close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

one map api, multiple domains

Thread begun 12/13/2009 12:42 pm by florianmagener266546 | Last modified 12/25/2009 3:25 pm by joe396415 | 5049 views | 4 replies |

florianmagener266546

one map api, multiple domains

Hi,
is it possible to have one google map api for various domain names that are directed to one domain or to embed the different google map api's ( for each domain name) in the same page under one domain?
At present if I type in a browser one domain name I get the error that it is the wrong api for that domain as it is being redirected to a different domain.

Please advise?

Sign in to reply to this post

Jimmy Wu

If you want to use the same map over again for different domains, you will have to get a different api key for each of the domains you are using it for.

If you are uploading the same pages to different domains, you will have to change the api key accordingly. On the page you have the map applied, find the map script that looks similar to this:
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAvZMU4-DFRYtw1UlTj_zc6hT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQcT1h-VA8wQL5JBdsM5JWeJpukvw">/*wagmp*/</script>

The key= portion stores the api key that is used. Replace that with the correct api key for each domain.

Sign in to reply to this post

Brad Lawryk

Hi Jimmy,

I don't think that is what the original poster meant. I am having the same issue as the original poster:

I have two domain names for example mysite.com and mysite.net both bring up the same website but the google map will only work for one of them.

Is there a work around this?

Thanks,
Brad

Sign in to reply to this post

Jason ByrnesWebAssist

you can find the currant servers domain name using the HTTP_HOST server variable:

php:
<?php echo((isset($_SERVER["HTTP_HOST"]))?$_SERVER["HTTP_HOST"]:""?>




Create a switch statement to select which key should be used based on that variable:

php:
<?php

switch ($_SERVER["HTTP_HOST"]) {
  case 
"www.mydomain.com"$key "key1"; break;
  case 
"www.otherdomain.com"$key "key2"; break;
  case 
"www.someotherdomain.com"$key "key2"; break;
  default: 
$key "default key"; break;  
}
?>





then change the script tag that connects to the google api to use the new $key variable:

php:
<script type="text/javascript"  src="http://maps.google.com/maps?file=api&v=2&key=<?php echo $key?>">/*wagmp*/</script>
Sign in to reply to this post

joe396415

Cool...I had this exact problem and this fix worked well!

thanks!!

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...