Forums / Developer / gmaplocation extension GoogleMaps Not recognizing my Key

gmaplocation extension GoogleMaps Not recognizing my Key

Author Message

Pierre SCALFATI

Saturday 22 August 2009 5:41:05 am

Hello,

I thought that my gmaplocation was working fine but it was just working fine locally. Once I published my site on my domain space, I had this message :

The Google Maps Api server rejected your request. This could be
because the API key used on this site was registered for a different
website.

Here is the code of my override template used to display my Google Map localisation:



 <div class="class-gallery">

        <h1>{$node.name|wash()}</h1>

    {section show=$node.data_map.image.content}
        <div class="attribute-image">
            {attribute_view_gui alignment=right image_class=medium attribute=$node.data_map.image}
        </div>
    {/section}

        <div class="attribute-short">
           {attribute_view_gui attribute=$node.data_map.description}
        </div>
 <p>&nbsp;</p>  
 {literal}  
   <script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key={ezini('SiteSettings','GMapsKey')}" type="text/javascript"></script>
<script type="text/javascript">
function MapViewer_{/literal}{$node.node_id}{literal}()

{
{/literal}
    var attribid = {$node.node_id};
    var mapid = 'map_{$node.node_id}';
    {if is_set($node.data_map.localisation.content.latitude)}
    var lat = {$node.data_map.localisation.content.latitude};
    var long = {$node.data_map.localisation.content.longitude};
    {else}
    var lat = 0.0;
    var long = 0.0;
    {/if}
    {literal}
    
    var map = null;
    var geocoder = null;
    var gmapExistingOnload = null;
    var marker = null;
    if (GBrowserIsCompatible()) 
    {
        var startPoint = new GLatLng(0,0);
        var zoom = 0;
        if(lat && long)
        {
          startPoint = new GLatLng(lat,long);
          zoom=16
        }
        map = new GMap2(document.getElementById(mapid));
        map.addControl(new GSmallMapControl());
        map.setCenter(startPoint, zoom);
        map.addOverlay(new GMarker(startPoint));
    }
}

if (window.addEventListener)
{
{/literal}
    window.addEventListener('load', MapViewer_{$node.node_id}, false);
{literal}
}
else if (window.attachEvent)
{
{/literal}
    window.attachEvent('onload', MapViewer_{$node.node_id});
{literal}
}
    {/literal}
</script>

I tried to enter the key directly in the code, but nothing. It works only on my local Macintosh.

If someone can help, it would be great.

André R.

Saturday 22 August 2009 5:57:49 am

Rember that you have to create one key pr domain, it seesm to work withouth key locally, so check your key.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Pierre SCALFATI

Saturday 22 August 2009 6:34:55 am

Hi André,

Yes I created just one key for my unique domain name.

First thing I noticed is that in my page source code, the ezpublish code remains as it is (it's not interpreted), I have the following line in my code :

Here is what is displayed in my source code:

<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key={ezini('SiteSettings','GMapsKey','site.ini')}" type="text/javascript"></script>

I tried to replace, typing : key="my_google_maps_key" (where my "my_google_maps_key" is the key that copy/paste from google api key generator for mydomain.com...

I noticed also something curious: the Localize button in the Ezpublish Admin Console doesn't work.

André R.

Saturday 22 August 2009 8:54:27 am

> the ezpublish code remains as it is (it's not interpreted)

It's inside a {literal} block, thats why.

Try the updated ezgmapslocation, it shouldn't have any of these issues and have some new features as well:
http://projects.ez.no/ezgmaplocation

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Pierre SCALFATI

Saturday 22 August 2009 8:54:48 am

Hello,

Believe it or not but what happened to me is really laughing. I must admit that I had no luck in the Google Key which was given to me by Google MAPS. In this code there's the letters "SEX' and as my routeur firewall is configured to block such words I had no display when I was adding the Key directly in my code !!!

My web site has nothing to deal with SEX, I must precise, but the Google Map algorithm which gave me the key was not inspired to put such letters in my key. I spent 1 day trying to solve this stupid problem.

For your information, what made me find the solution is that I typed directly the javascript generated in my Browser and I was astonished to get the reply, this time, from my Firewall, saying : "BLOCKED".

That's it.

So, if such problem happens, be sure before that it's not a sex affair :-)
Thank you Mister Google MAPS.

Best Regards.