I'm wondering if there is a way to load google map libraries in separate HTTP requests? My interest is to know if it is possible to do it as I can't find any related doc...
For example:
<script type="text/javascript" scr="//maps.google.com/maps/api/js?language=en&sensor=false"></script>
<!--
First map which does not need extra google map libraries
-->
<script type="text/javascript" scr="library_url"></script>
<!--
Second map which needs extra google map libraries
-->
Thanks
Related
We are trying to integrate localization into our HERE JS map display. This involves both the map labels and the UI options.
We are using these JS libraries:
<script src="https://js.api.here.com/v3/3.0/mapsjs-core.js" type="text/javascript" charset="utf-8"></script>
<script src="https://js.api.here.com/v3/3.0/mapsjs-service.js" type="text/javascript" charset="utf-8"></script>
<script src="https://js.api.here.com/v3/3.0/mapsjs-ui.js" type="text/javascript" charset="utf-8"></script>
<script src="https://js.api.here.com/v3/3.0/mapsjs-mapevents.js" type="text/javascript" charset="utf-8"></script>
On our website, we are using language codes following the ISO language codes: http://www.lingoes.net/en/translator/langcode.htm
However, when I try to pass in a standard code like "hi-IN" into the defaultLayers creation:
var ui = H.ui.UI.createDefault(hereMap, maptypes, "hi-IN"); // simplified, language code is actually passed in
Looking at the HERE API documentation: https://developer.here.com/api-explorer/maps-js/maps/map-multi-language-support it seems like I'm using the right kind of language code, but I get "Uncaught Error: Locale [hi-IN] is not supported.". Am I misunderstanding something or using something incorrectly? Is there a list of all the Locales are supported?
If it's not supposed, does anyone have recommendations on how to create our own translations for the map labels like "normal" and "satellite"?
Currently "hi-IN" is not supported yet.
About the map labels in UI. Please see below thread in SOF.
The snipped sample code is about creating own UI control.
How do I get a Terrain Map in UI Controls HERE Maps v3.1
I hope this help.
I got error when using the Google map
You have Included the Google Maps API multiple times on this page.
This may cause unexpected errors.
Google Maps API warning: SensorNotRequired
Google Maps API warning: NoApiKeys but I have a API keys
This is my footer tag
<script src="https://www.gstatic.com/firebasejs/4.1.2/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/geofire/4.1.2/geofire.min.js">
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=">
</script>
Your API key is missing
It looks like you have not included the key in your Google maps script request.
Google has an official guide for how to set up everything
The take away in your case is that you included the script like so:
<script async defer src="https://maps.googleapis.com/maps/api/js?key=">
</script>
You're missing the key parameter in the url. This is how google wants your request
<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"
type="text/javascript"></script>
Notice the part where it says key=YOUR_API_KEY That's where you need to put your API key.
The API key looks like this: (not an actual key)
AIzaSyBMh448pWbvhyvsqY4OasYmam4ppD2CHPM
Your final link should look like this:
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBMh448pWbvhyvsqY4OasYmam4ppD2CHPM"
type="text/javascript"></script>
More than one request
The other warning:
"You have Included the Google Maps API multiple times on this page"
indicates that your have tried to request Google maps API more than once on the same page. I don't see that in your example code. You may have another request someplace else like in the header. Don't use more than one per page.
Edit:
After looking at your page source I found this:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
This is the extra request that's causing the error where the API is requested multiple times.
I am trying to run Google Map on a WordPress site. The code is running perfectly on this JSFIDDLE but when I take it to WordPress I am getting this error
Google Maps API warning: SensorNotRequired:
https://developers.google.com/maps/documentation/javascript/error-messages
I also tried this code
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>
but the result is same.
Finally I tried to get a key from API and use it
<script src="https://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxxxxxxxxxxxxx&callback=initMap"
async defer></script>
and now I am getting this error
Uncaught TypeError: window.initMap is not a function
can you please let me know why this is happening and how I can fix it?
Instead of:
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>
Try:
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?v=3"></script>
From the Google Maps API documentation:
The sensor parameter is no longer required for the Google Maps
JavaScript API. It won't prevent the Google Maps JavaScript API from
working correctly, but we recommend that you remove the sensor
parameter from the script element.
under some conditions (that only god or google knows), this is not sufficient to provide the js tag...
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
... in order to load the Google V3 API. I must provide in these cases the following tag that loads the corresponding main.js:
<script type="text/javascript" src=" http://maps.gstatic.com/intl/pt_br/mapfiles/api-3/8/7/main.js"></script>
Because this file doesn't load automatically from the first script.
Do someone already experienced the same behaviour?
Probably that's because you don't specify api-version in script tag. This works fine for me:
<script src="http://maps.google.com/maps/api/js?v=3.5&sensor=false"></script>
Since Google is going to pull the plug out of their translator API (by the end of this year), Is there someone who already found a good (free or $) alternative?
Try TranslateThis on http://translateth.is/...
Is very simple! To see the effects try this piece of code:
<!-- Begin TranslateThis Button -->
<div id="translate-this"><a style="width:180px;height:18px;display:block;" class="translate-this-button" href="http://translateth.is/">Translate</a></div>
<script type="text/javascript" src="http://x.translateth.is/translate-this.js"></script>
<script type="text/javascript">
TranslateThis();
</script>
<!-- End TranslateThis Button -->
Don't worry about the button aspect... You can customize it!
Google is offering and alternative to website translation. Its the GOOGLE WEB ELEMENTS, and some code from the google's web elements homepage itself for translation
<!-- Google Translate Element -->
<div id="google_translate_element" style="display:block"></div><script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: "af"}, "google_translate_element");
};</script>
Other alternatives:
Microsoft Translation Tools
they offer HTTP, SOAP and SDK interfaces for integration.
If you need just language detection, there is free API:
http://detectlanguage.com
It produces JSON output, just like Google Translate.