Upgrading Google Maps javascript v2 to v3 using Business Client IDs - javascript

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,

Related

SAP Cloud SDK for Javascript: difference between pre-delivered OData services VS self-generated clients

Is there any difference (extra-code) between the predelivered OData client services and the ones I would have generated myself using #sap-cloud-sdk/generator, provided I have the exact same OData service version?
From my unit test of BusinessPartner, it looks it works the same. Can anyone confirm?
Thank you.
Your assumption is correct. The code that we ship in packages like #sap/cloud-sdk-vdm-business-partner-service is the exact same code you'd get if you generated it yourself, based on the service definition from api.sap.com.
We obviously generate some more things on the side, like a package.json and documentation and so on, but the code is identical.

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

Cannot find Google Maps key

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

Here maps autocomplete js api

Here maps added autocomplete function to its geocoder api
http://autocomplete.geocoder.cit.api.here.com/6.2/suggest.json
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&query=Pariser+1+Berl
&beginHighlight=<b>
&endHighlight=</b>
It is complete new and not well documented right now. I do not know how to call it with js api. Do anybody use it with the js api or know how to use it with js api?
Most js api acts as wrapper class for geocorder, so i want to prefer using existing wrapper before building my own.
There is now a project to wrap the HERE Maps JS API, you can find it on NPM here:
https://www.npmjs.com/package/node-heremaps
If you're looking to display maps in the browser, I've started working on a project for a React integration here:
https://www.npmjs.com/package/react-here-maps
And you can of course just include the HERE Maps script directly.
The HERE Maps JS API doesn't seem to have an existing wrapper for it (yet?). Easiest thing would probably be to call the URL via jQuery ($.get) or some such until it's integrated. The JS API doesn't do much more than create a JSON-P request and hand you the result back...
https://developer.here.com/api-explorer/rest/geocoding_suggestions/geocoding-autocomplete
Refer To This Link For Further Demo and Implementation
For a full working example see fiddle at https://jsfiddle.net/Lhj2mnpd/.
https://autocomplete.geocoder.cit.api.here.com/6.2/suggest.json?query=1+Main+Street&app_id=hereid&app_code=herecode&beginHighlight=%3Cb%3E&endHighlight=%3C%2Fb%3E
Moving forward with your code
Just Replace
your purchased api key and code like
http://autocomplete.geocoder.cit.api.here.com/6.2/suggest.json?app_id={"purchasedappid here "}&app_code={"purchased appcode here "}&query=Pariser+1+Berl&beginHighlight=&endHighlight=`

Subgurim Maps control causing javascript errors ("GUnload undefined")

I want to implement a Google Map on my .NET page. I used the tool from Subgurim,
I could add the components well, but when browsing the page, I get tons of Javascript errors like:
GUnload is undefined
And the map is not shown. I read many posts describing my problem, but the only hint seems to be the maps API was not loaded.
I got a API key from Google. I am not very familiar with the interface; I activated both Google maps API services (v2 and v3) and got a key from "API access" for both separately.
I downloaded the Subgurim Maps version 3.4.1.
string streetAddress = "100 Russell St. Melbourne. VIC. 3000. Australia";
string mapKey = ConfigurationManager.AppSettings["googlemaps.subgurim.net"];
Subgurim.Controles.GeoCode geoCode = GMap1.getGeoCodeRequest(streetAddress, mapKey);
Subgurim.Controles.GLatLng gLatLng = new Subgurim.Controles.GLatLng(geoCode.Placemark.coordinates.lat, geoCode.Placemark.coordinates.lng);
GMap1.setCenter(gLatLng, 16, Subgurim.Controles.GMapType.GTypes.Normal);
Subgurim.Controles.GMarker oMarker = new Subgurim.Controles.GMarker(gLatLng);
GMap1.addGMarker(oMarker);
Without access to your code, I deduce that you have included the Version 3 <script> tag but have coded the map in Version 2. Thus your code includes lots of G objects, including GUnload, which are not included in Version 3 and the API knows nothing about.
The immediate solution would be to include the Version 2 script. The full solution (since Version 2 is deprecated) is to convert the map to Version 3. I've no idea whether Subgurim makes that possible.
The new (short) key works for Version 3 and Version 2.
The problem was that the GMap control I used was in part of the page that was set visible="false". This caused the Javascript error.

Categories

Resources