Google maps API key issues

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
11/6/2018 10:23:38 AM
Gravatar
Total Posts 10

Google maps API key issues

Hi all,

We are having issues displaying Google maps on our site (maps display with "For development purposes only" watermark) and we are seeing the following in the browser console

      util.js:224 Google Maps JavaScript API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys

 

My client has provided an API key from their Google Cloud account and I have added this to the API section in Mojoportal as well as the <add key="GoogleMapsAPIKey" value=".... section in the web.config for the site but the issue persists.

I also installed the Google API checker chrome extension and it reports the following

      Maps Platform Report

      ERROR: This site doesn't seem to be using an API key. Keyless usage will soon be deprecated. Please set up and secure a key for your project.

Am i missing any steps or has anyone else seen similar issues that can offer help?

 

This used to work fine but I appreciate that Google changed their API licensing approach which I guess has caused this.

Regards

Andy

11/6/2018 1:00:48 PM
Gravatar
Total Posts 2239

Re: Google maps API key issues

Hi Andy,

What version of mojoPortal are you running?

If it's pre-2.7, you'll need to upgrade. Short story: mojo wasn't using the api key but 2.7 does and also provides a method (iframe embed) for not using the key.

Long story: when mojo originally implemented Google Maps, the api key was required. Google removed the api key requirement at some point and mojo no longer used it for connecting to the maps api. Google then decided they wanted to require it again but didn't make any breaking changes and mojoPortal wasn't updated to use the api key. Google decided to start charging for use of their service (sort of, you have to give them a credit card even if you're a small site that will never hit their quota) and they started placing the developer purposes banner on the maps when the key wasn't used. We re-implemented the key in mojo but before we made the 2.7 release we figured out how embed maps without using an api key, using an iframe embed. The api method provides a lot more functions but the iframe embed method is a lot easier and is sufficient for most sites. Stay tuned for when Google changes things again. They're good at that, it keeps them relevant (as if they need help with that, lol). ;-)

Thanks,
Joe

11/6/2018 1:13:00 PM
Gravatar
Total Posts 10

Re: Google maps API key issues

Hi Joe,

Thanks for the update, I appreciate it.

Just checked and this is Version 2.4.0.4 MSSQL of MP..............so..................uh............old :)

We inherited support for this and the Google change has literally killed the main purpose of the site for the customer which isnt good so I am going to have to try and fast track this upgrade and would hope to be able to just use the API key to remove any development if possible.

So if we jump to 2.7 at the very least you think that would do what we want?

Don't want to seem n00b (well, I am I guess) but is the upgrade a straightforward one i.e. run an exe etc?

Cheers

Andy

11/6/2018 3:35:19 PM
Gravatar
Total Posts 2239

Re: Google maps API key issues

Hi Andy,

Understood, we can help you with the upgrade, if you like. Open a ticket with us and we can discuss.

Thanks,
Joe

11/13/2018 5:36:31 AM
Gravatar
Total Posts 10

Re: Google maps API key issues

Hey Joe,

Sorry to bother again, just to confirm..........version 2.7 should resolve the API key issue (we have one from the customer) through inputting it into the administration API area?

Regards

Andy

11/13/2018 1:31:01 PM
Gravatar
Total Posts 2239

Re: Google maps API key issues

Hi Andy,

If you upgrade to 2.7 you will be able to use the API Key AND be able to use a new method that doesn't require the API Key. The API Key gives you a bit more control over what is displayed on the map but for most purposes the new method without the API is sufficient.

Thanks,
Joe

1/9/2019 9:32:53 AM
Gravatar
Total Posts 10

Re: Google maps API key issues

Hey Joe,

Hope you had a good Christmas and NY :)

I have managed to run the upgrade scripts against one of our test servers for this solution and while the site initially looks to work fine, I am seeing the occasional blip in functionality around mapping. I haven't even got near the Google API issue yet

The error we are seeing is as below.

2019-01-09 12:09:50,438 INFO (null) - (null) - (null) - mojoPortal.Web.Global - Application Started. 
2019-01-09 12:10:21,842 ERROR 195.89.171.5 - en-US - /map - mojoPortal.Web.Global -  Referrer(https://**our site url**/map) useragent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 
System.ArgumentException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
   at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument)
   at System.Web.UI.WebControls.TextBox.LoadPostData(String postDataKey, NameValueCollection postCollection)
   at System.Web.UI.WebControls.TextBox.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)
   at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 

Do you have any thoughts or suggestions that might help?

Regards

Andy

1/9/2019 1:18:34 PM
Gravatar
Total Posts 2239

Re: Google maps API key issues

Hi Andy,

Christmas was good. I hope the same for you!

Are you having trouble with the maps or are you just finding this error in the logs?

Do you have any other controls on the page with the map?

Thanks,
Joe

1/10/2019 9:53:35 AM
Gravatar
Total Posts 10

Re: Google maps API key issues

Hi Joe,

Thanks for the reply.

This is specifically an area that is not part of the base MojoPortal solution but a piece of dev work to add a control to it that filters some values in a JavaScript data table.

However, it works absolutely fine when the solution is using MP 2.4 (the previous version) and breaks with the "<pages enableEventValidation=" error previously mentioned after MP is upgraded to version 2.7 so I am trying to work out what has changed within MP that would cause that issue.

The site works absolutely fine when accessed over http but only displays the issue when accessed using https (as it will be on live)

Again, on MP 2.4 this works fine

 

Regards

Andy

1/22/2019 7:53:23 AM
Gravatar
Total Posts 10

Re: Google maps API key issues

Hi Joe,

Ok, besides the issues that we are facing with the upgrade, I quickly tested the Google maps functionality and have noted that we are still getting the "developer" watermark on any use of Google maps

I have placed our API key in both the site settings and the web.config as well as making sure that our site is included in the API configuration on Google's side

Can you help or advise please?

 

Thanks

Andy

1/31/2019 4:25:38 AM
Gravatar
Total Posts 10

Re: Google maps API key issues

Hi Joe,

Are you able to offer some assistance on the above please?

Regards

Andy

2/6/2019 6:11:29 AM
Gravatar
Total Posts 10

Re: Google maps API key issues

Hi Joe,

We really are stuck here and I would appreciate some help if you could afford the time.

As mentioned, we are now successfully upgraded to v2.7 of MP but we are still seeing the Google watermarks on the maps.

I have placed our API key in both the web.config of the site and in the API area of the CMS administration area.

The API key has had our current URL white-listed etc so that should be fine.

The upgrade caused other issue in customised areas of the solution but if we cannot get v2.7 to work with Google, then there will obviously be no appetite to upgrade and fix these

Please help

Regards

Andy

2/8/2019 2:49:48 PM
Gravatar
Total Posts 2239

Re: Google maps API key issues

Hi Andy,

Thank you for your patience. I apologize for the radio silence. We recently changed our email platform and in doing so we also changed our email client. It's a silly thing but we got completely side-tracked and the three of us that pay attention to mojoPortal forums didn't setup our new email client to show us the mojoPortal notifications (the new system pretty much hides all folders and requires you to manually "favorite" each one you want to see). Such a silly mistake that I'm afraid is going to affect us for a little while.

So, from what I'm gathering your not able to use Google Maps because the API Key apparently isn't being used properly. If you're using HTTP, it's all fine but when using HTTPS, it's showing the watermark. Is that all correct?

Some background: When we re-enabled the API key, we didn't have to do too much to make it work, just uncommented the line of code that had been commented out years ago when Google had gotten rid of the key.  We then, some months later and before releasing 2.7, figured out away to not need the API Key by utilizing the Google Maps embed functionality. We updated the code to offer UseIframe as an option and defaulted it to true in the features of mojoPortal that use the map. The iframe/embed method doesn't allow for other features of google maps (local search and driving directions for instance) but it makes using the maps very easy for regular site owners (i.e., they don't have to go get an API Key).

Looking at the code, in Web\Controls\Google\LocationMap.cs, I can see where HTTP vs HTTPS could be playing a role in what is going on with your site. If "EnableLocalSearch" is true, the API Key exists, and the current protocol is 'http', then we tell LocationMap.cs to use the Old Api (old as in really old v2). This is on lines 512-554.  That particular code actually didn't change at all since we took over the project (pre 2.5). 

If you don't need the Local Search functionality, I would suggest setting your instance of the locationMap control to UseIframe=true and seeing what that does for you. Google deprecated the LocalSearch feature a very long time ago so mojoPortal really shouldn't even give it as an option at this point, to be honest.

We're testing a new release right now but if we need to make some adjustments to make this work for you, we'll do that before releasing.

Again, thank you for your patience.

Best,
Joe Davis

You must sign in to post in the forums. This thread is closed to new posts.