Cannot find Google Maps key - javascript

I realize that this may be a moot question, and it may not be possible to find what I am asking, but here goes nothing.
I would like to find the API key or its location in code/database which is being used by Google Maps on my website.
It's a WordPress website, and I am currently using a theme called Directory Engine from Engine Themes.
Please see the URL.
The map block shows an error, after initially loading for a second.
I have used different plugins, even combed through the code to figure out where it could be, but couldn't
I know this is a long shot, and any help would be much appreciated.

Go to the following URL and generate a key.
https://developers.google.com/maps/documentation/javascript/get-api-key
in your code replace the following link.
//maps.googleapis.com/maps/api/js?sensor=false&signed_in=false&ver=1&key=YOUR_GENERATE_KEY
after that, your issue will be fixed.

To correctly use the google maps api you must include YOUR_API_KEY in the code
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"
async defer>
</script>
your code has
<script type="text/javascript"
src="//maps.googleapis.com/maps/api/js?sensor=false&signed_in=false&ver=1">
</script>
sign up for your own API key here and place that in the code above
Search your code base
if you are having trouble locating where in your code base the api is set you could try to use a command line script on your root folder
grep -r "googleapis"
Search your Database
you could try to do a sql dump then search that file for the string

Related

How to fix "this page can't load google maps correctly" error

I have run a website that is probably 10 years old at this point that has a map with custom points plotted on it. Recently I've noticed that this map says "For Development Purposes Only" and has an error alert: "This page can't load Google Maps correctly" and it says "Are you the owner of the website?"
I went through the process of setting up billing and generated an API key. But when I plug that key into the ONLY spot where there's an API key in the existing code, it fails with a "Oops! Something went wrong.
This page didn't load Google Maps correctly. See the JavaScript console for technical details."
This is the code difference:
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAYuhugTQ8HWA2RX4tkBQyIbvbe-f2nKDf2uCI5Rwpq3vfPBRkDwxy87YO1o-kJbvMl8dG_FNpRQ" type="text/javascript">
And the new version:
<script src="http://maps.google.com/maps?file=api&v=2&key=AIzaSyDLRgUHjuLTn7s629OxjVujuHOROcvB8" type="text/javascript">
After Googling and searching I found a bit of different syntax and thought perhaps that was the problem, so I tried that. It also failed:
<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDLRgUHjuLTn7s629OxjVujuHOROcvB8" type="text/javascript">
(Note, I have altered these keys, they are not MY keys.)
I was hoping that the new API key would simply plug into the existing code and work, as I am not sure even where to start in the full code. Does anyone know if there are any glaring errors with this? Am I missing something obvious?
I know I haven't included the pages and pages of code, but that's because my impression was that an api-key is used once and the code should work whether it's key A or key B, as long as the key is correct.
Is my key perhaps not for use with Google Maps but some other key? Is there some additional "switch" to turn on for this to work?
Any help would be greatly appreciated. Thank you in advance.
In the hour or so since posting I believe I've answered my own question: AFTER making the API key, there's an additional step, probably obvious to any programmer but not to me at the time...you have to "Enable" the APIs for use with your site.
I did this here: https://console.developers.google.com

What type of magic is LinkedIn doing with their JS SDK? script body and src are present, plus body in weird format

I want to integrate LinkedIn sharing on my page.
Reading the documentation that LinkedIn provides here:
https://developer.linkedin.com/docs/getting-started-js-sdk
.. I was surprised to see they require this script tag in the head secion of my page
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: [API_KEY]
onLoad: [ONLOAD]
authorize: [AUTHORIZE]
lang: [LANG_LOCALE]
</script>
I don't get what is happening here. First of all, w3schools says that """Note: If the "src" attribute is present, the element must be empty.""" (https://www.w3schools.com/tags/tag_script.asp).
I also went here: https://html.spec.whatwg.org/multipage/scripting.html#the-script-element
(I'm not 100% sure how authoritative this is...but looks authoritative based on the format and length :P) - it also says there that if there's a src attribute, then the body should basically be empty - in any case - LinkedIn's script syntax is not explainable by these 2 resources.
So does anyone know what's up with the script body syntax? Are those JS labels? And if so, I don't get how they're used. I thought labels are used with continue/break statements, to get out of loops. I don't understand how LinkedIn's API can get information from me if I provide it in that syntax.
Is the script body somehow fed to the script, and it parses it itself?
Can someone please explain to me what's going on?
Thanks!
What you said is correct. When the src attribute is added, the body of the script is not executed. There is a way to get around this however. That's by retrieving the script tag, extracting the innerHTML and using eval on it. You will need to of course do that on document ready.
I don't know how LinkedIn does it exactly, but HTML standards didn't change for them nor the order of loading, so either they use something similar to what I explained or some more clever way of parsing the body of the script.
Other notes to consider: instead of using document ready event, you could bind that into your library. As in retrieve the last available script tag, and extract the body, at the time of load of your library, that will be the last element loaded either way, so you should be able to retrieve the code without using any events. (That would need testing, but DOM elements are loaded synchronously, top-down approach).
Obviously using eval is not recommended, its quite slow, but definitely provides the functionality you're looking for.
PS. Forgive any formatting errors. I'm typing this from my mobile, 2k miles away from home. Otherwise I'd be more than happy to even provide some sample code snippets and do the above testing myself.

loading a external content so that searchable by Google for SEO purposes

I'm working on a project where we'd like to load external content onto a customers site. The main requirements are that we'd like the customer to have as simple of an include as possible (like a one-line link similar to Doubleclick) and would preferably not have to be involved in any server-side language. The two proposed ways of doing this were an iframe or loading a javascript file that document.write's out the content.
We looked more at the latter since it seemed to produce more reliable legibility and simplicity for the end user - a single line of Javascript. We have been hit with the reality that this will be indexed unpredictably by Google. I have read most of the posts on this topic regarding javascript and indexing (for example http://www.seroundtable.com/google-ajax-execute-15169.html, https://twitter.com/mattcutts/status/131425949597179904). Currenlty we have (for example):
<html>
<body>
<div class='main-container'>
<script src='http://www.other.com/page.js'></script>
</div>
</body>
</html>
and
// at http://www.other.com/page.js
document.write('blue fish and green grass');
but it looks like google indexes this type of content only sometimes based upon 'Fetch As Google' used in Google's webmaster tools. Since it does sometimes work, I know it's possible for this indexing to be ok. More specifically, if we isolate our content to something like the above and remove extraneous content, it will index it each time (as opposed to the EXACT SAME Javascript in a regular customer html page). If we have our content in a customer's html file it doesn't seem to get indexed.
What would be a better option to ensure that Google has indexed the content (remote isn't any better)? Ideas I have tried / come across would be to load a remote file in for example PHP, something like:
echo file_get_contents('http://www.other.com/page');
This is obviously blocking but possibly not a deal-breaker.
Given the above requirements, would there be any other solution?
thx
This is a common problem and I've created a JS plugin that you can use to solve this.
Url: https://github.com/kubrickology/Logical-escaped_fragment
Make sure to use the: __init() function instead of standard DOM ready functions and you know for sure that Google is able to index.

Upgrading Google Maps javascript v2 to v3 using Business Client IDs

I am using this link for Upgrading Google Maps JavaScript Application v2 To v3. Basically my approach is to get the output from api, parse it and load it using MapKit framework, which i am succeeded in doing it using this code.
My problem : As per the documentation,if we are using google maps for Business customer, we will need to use a Client ID in place of a Key.
so if I use this code:
<script src="https://maps.googleapis.com/maps/api/js?v=3&client=gme-myclientId&sensor=false" type="text/javascript"></script>
i am getting following output, where all the locations are plotted at single point (probably centre) :
if i use this code:
<script src="https://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>
i will get the expected (correct) output as follows:
I also ran through this documentation for correct use of client id, but dint help.
I am using the same client id that was used for v2, hope that should not create any problem.
Thanks for all the comments to my question, which made me to solve the problem. So, i thought of sharing the solution.
when i am not using the client id,
<script src="https://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>
the response structure is
"overview_path": [{
"jb": 37.785610000000005,
"kb": -122.41127000000002
}, … ];
But, on using the client id, say gme-myClientId
<script src="https://maps.googleapis.com/maps/api/js?v=3&client=gme-myClientId&sensor=false" type="text/javascript"></script>
the response structure is
"overview_path": [{
"hb": 37.785610000000005,
"ib": -122.41127000000002
}, …];
So, variation in jb,kb to hb,ib was causing the problem, since i was using the variables as key to get the values.
I was using a third party Code which internally follows this procedure.
I mailed Google enterprise support and they replied me back saying i might be using some of the undocumented variables in my Javascript library. The variable names are automatically generated when the library is minified and can (and often do) change on every release they push. The correct way is to use the documented API methods only.
link for using documented API methods can be found
Here
i modified my code to use like the below
var latT = someLocationObject.lat();
var longT = someLocationObject.lng();
and it worked for me.
Well, to use a client id like "gme-XXXXX" you need to buy a Google Maps for Business licence. Have you already buy one ?
Regards,

Does google robot index text from javascript document.write()?

Lets say I have this:
<script type="text/javascript">
var p = document.getElementById('cls');
p.firstChild.nodeValue = 'Some interesting information';
</script>
<div id="cls"> </div>
So, google robots will index text Some interesting information or not?
Thanks!
AFAIK, google robot will now indexing AJAX and Javascript stuff.For reference please follow:
http://www.submitshop.com/2011/11/03/google-bot-now-indexing-ajax-javascript
Get google to index links from javascript generated content
Update
SearchEngine watch has recently mentioned that Google bot has been improvised to read JavaScript, to quote exactly
it can now read and understand certain dynamic comments implemented
through AJAX and JavaScript. This includes Facebook comments left
through services like the Facebook social plugin.
We've had a need to hide pieces of information on pages from GoogleBot. As the information wasn't extremely sensitive, we've used document.write()-s to avoid searchbots indexing content in question.
Later in 2011 Q3 I've found that GoogleBot did index the scripted content, so I'm pretty sure now that Google is indexing much more than just fetching URLs from content, even though it's really not documented anywhere deeply.
Google doesn't index the JavaScript code or the generated content. You will only see it in the cache because the cached page consists of the complete file including the JavaScript code and your browser renders it. Google does scan JavaScript for URLs to crawl, so if the code is pulling content from an external file via Ajax, etc., there's a chance that the external file will also be indexed, but separate from the parent page. If you want the content to be indexed, it's got to be in plain HTML. Good luck!

Categories

Resources