Jump to content

Google Maps API Key?


mark1million

Recommended Posts

  • Moderators

Hey guys this may seem odd but in the settings page of admin (/admin/index.php/settings) there should be a place to input your google maps api key, on the dev version my field is missing, can i add this in to the local congig directly or where does it go.

By the way google maps work fine never had an issue but there is an error in the console of chrome stating about the api

Cheers.

post-75-0-71428700-1462023630_thumb.png

Link to comment
Share on other sites

  • Moderators

Ok i have figured it out for anyone wishing to comply with google here is the fix.

open up your /core/templates/core_htmlhead.tpl or ,php depending if you have converted to php files, the line you are looking for is,

<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=true"></script>

You need to replace that with

<script async defer src="https://maps.googleapis.com/maps/api/js?key=PLACE YOURKEY IN HERE&callback=initMap"></script>

Replace PLACE YOURKEY IN HERE with your generated key

To generate your API key from Google log in to your Google account and go to https://developers.g...get-api-key#key

Remember this modification will get overwritten on any update as its in the core_htmlhead.tpl

Link to comment
Share on other sites

  • 3 months later...

Thank you! I get this in my console now

intended for developers. Do not paste any code here given to you by someone else. It may compromise your account or have other negative side effects.
external.js:264 Object
util.js:207 Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys

anything to worry about?

Link to comment
Share on other sites

Yeah, but you still forgot the ?key= part, instead, you only specified the API Key itself

What you've got

<script async defer src="https://maps.googleapis.com/maps/api/js?YOUR_API_KEY&callback=initMap" type="text/javascript"></script>

Try this

<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" type="text/javascript"></script>

And replace YOUR_API_KEY with the API Key. Note the ?key=

Edited by web541
Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...
  • 2 months later...

Hi all,

This has fixed the "my flights map" under pilot center.

But I have not been able to get google maps to load the KMZ file with my routes. 

I have separate page for each area of the world we fly in (using the internal page function).

Can some one that has gotten this to work please post sample code.

 

Thank you

I wait your reply.

David

Oz Flyer.

 

Link to comment
Share on other sites

  • 5 months later...
  • 4 months later...
<?php if(!defined('IN_PHPVMS') && IN_PHPVMS !== true) { die(); } ?>
<?php
/**
 *     STOP! HAMMER TIME!
 *
 * ====> READ THIS !!!!!
 *
 * I really really, REALLY suggest you don't edit this file.
 * Why? This is the "main header" file where I put changes for updates.
 * And you don't want to have to manually go through and figure those out.
 *
 * That equals headache for you, and headache for me to figure out what went wrong.
 *
 * BUT BUT WAIT, you say... I want to include more javascript, css, etc...!
 * Well - in your skin's header.tpl file, this file is included as:
 *
 * Template::Show('core_htmlhead.tpl');
 *
 * Just add your stuff under that line there. That way, it's in the proper
 * spot, and this file stays intact for the system (and me) to be able to
 * make clean updates whenever needed. Less bugs = happy users (and happy me)
 *
 * THANKS!
 */
?>
<script type="text/javascript">
var baseurl = "<?php echo SITE_URL;?>";
</script>

<link rel="stylesheet" media="all" type="text/css" href="<?php echo fileurl('lib/css/phpvms.css')?>" />
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo Config::Get('PAGE_ENCODING');?>" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&callback=initMap"
  type="text/javascript"></script>
<script type="text/javascript" src="<?php echo fileurl('lib/js/jquery.form.js');?>"></script>
<script type="text/javascript" src="<?php echo fileurl('lib/js/phpvms.js');?>"></script>

<?php
echo $MODULE_HEAD_INC;

 I make change  in       /home/vapersia/ms.virtual-flights.ir/core/templates/core_htmlhead.php   and still map not work what i must do ?

Link to comment
Share on other sites

  • Moderators

As I can see, you are using a different template from the default phpVMS template. This means that you will have to update the core_htmlhead.php of the template that you are currently using. This can be found in your_phpvms_directory/lib/skins/ocean_blue/core_htmlhead.php. Update it and let us know if that solves the issues.

Link to comment
Share on other sites

25 minutes ago, servetas said:

As I can see, you are using a different template from the default phpVMS template. This means that you will have to update the core_htmlhead.php of the template that you are currently using. This can be found in your_phpvms_directory/lib/skins/ocean_blue/core_htmlhead.php. Update it and let us know if that solves the issues.

<?php
/**
 * 	STOP! HAMMER TIME!
 * 
 * ====> READ THIS !!!!!
 * 
 * I really really, REALLY suggest you don't edit this file.
 * Why? This is the "main header" file where I put changes for updates. 
 * And you don't want to have to manually go through and figure those out.
 * 
 * That equals headache for you, and headache for me to figure out what went wrong.
 * 
 * BUT BUT WAIT, you say... I want to include more javascript, css, etc...! 
 * Well - in your skin's header.tpl file, this file is included as:
 * 
 * Template::Show('core_htmlhead.tpl');
 * 
 * Just add your stuff under that line there. That way, it's in the proper
 * spot, and this file stays intact for the system (and me) to be able to
 * make clean updates whenever needed. Less bugs = happy users (and happy me)
 * 
 * THANKS!
 */
?>
<script type="text/javascript">
var baseurl = "<?php echo SITE_URL;?>";
var geourl = "<?php echo GEONAME_URL; ?>";
</script>

<link rel="stylesheet" media="all" type="text/css" href="<?php echo fileurl('lib/css/phpvms.css')?>" />
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo Config::Get('PAGE_ENCODING');?>" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&callback=initMap"
  type="text/javascript"></script>
<script type="text/javascript" src="<?php  echo fileurl('lib/js/jquery.form.js');?>"></script>
<script type="text/javascript" src="<?php echo fileurl('lib/js/phpvms.js');?>"></script>
<?php

echo $MODULE_HEAD_INC;

now i change the Skin (Ocean Blue) file  still not work

Link to comment
Share on other sites

5 minutes ago, servetas said:

Remove the "async defer" tags from the google maps script.

removed still nothing 

i get code from google that's not work 

i dont know what i must do 

 

lol i pres ctrl+f5  and it work when i reload page again gone and error :D  

 

my site fu... up

Edited by ayhan041
Link to comment
Share on other sites

8 minutes ago, servetas said:

Check the source of your website using your browser. It seems that you include the google maps twice in your website (lines 21 and 24-25). I do not know what can cause this but you should only have line 21 from your website's page source.

your mean this section?

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&callback=initMap"
  type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&callback=initMap"
  type="text/javascript"></script>

 

Edited by ayhan041
Link to comment
Share on other sites

  • Moderators

I do not understand your question but you will have to remove this:

<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&callback=initMap"
  type="text/javascript"></script>

and use only this:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&sensor=true"></script>

Check your page source that includes two different calls for the google maps api.

Link to comment
Share on other sites

5 minutes ago, servetas said:

I do not understand your question but you will have to remove this:


<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&callback=initMap"
  type="text/javascript"></script>

and use only this:


<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&sensor=true"></script>

Check your page source that includes two different calls for the google maps api.

aha find that line sir and change it  now my source changed to this

<link rel="stylesheet" media="all" type="text/css" href="<?php echo fileurl('lib/css/phpvms.css')?>" />
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo Config::Get('PAGE_ENCODING');?>" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&sensor=true"></script>
<script type="text/javascript" src="<?php  echo fileurl('lib/js/jquery.form.js');?>"></script>
<script type="text/javascript" src="<?php echo fileurl('lib/js/phpvms.js');?>"></script>

i think  my key has problem cuz still not work i do what google say step by step something goes wrong 

anyway let it go 

 

thanks for your help sir ♥

Link to comment
Share on other sites

  • Moderators

You have included the google maps with the following code:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&sensor&callback=true"></script>

This is wrong. Replace it with this:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&sensor=true"></script>

Let me know if it works.

Link to comment
Share on other sites

5 hours ago, servetas said:

You have included the google maps with the following code:


<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&sensor&callback=true"></script>

This is wrong. Replace it with this:


<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyBTq3EcPWYUMAJ27n-IzcnQMKBGIWlxjsE&sensor=true"></script>

Let me know if it works.

thank you sir  i change api key and replace resource and now map work .  but i got new problem with that 

 

zyhn_ss.jpg

Edited by ayhan041
Link to comment
Share on other sites

  • 1 month later...

With help from WES on Discord I have now got all the map on the WEB site side working.

But none of the map views from within the Admin side are working still get "Opps! Something went wrong" error.

So far I have only changed the line to: 

<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=MY_KEY&sensor=true"></script>

in the file /core/templates/core_htmlhead.tpl

Is there any other changes to be made?

If so which file and where do I find them?

Thank you.

I await your help.

David.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...