Best way to implement google maps - javascript

I found two way to implement google maps.
The First One
<script src = "http://maps.googleapis.com/maps/api/js"></script>
The Second One
<script type="text/javascript" src="http://www.google.com/jsapi?key=....key"></script>
my questions :-
1- What is difference between them?
2- Can I download (save) a part of google maps (my country map or city) to my localhost?

For your second question
By Broswer Google maps can only be executed using internet. Eventually local copy are actually not allowed and above all does not work. Google Maps can used only as a service and not as a local library.
For Mobile you can access (and also edit) your maps locally eg see this

In HTML5, you no longer need to define the type attribute for JS includes, so this format works:
<script src = "http://maps.googleapis.com/maps/api/js"></script>
Additionally, you are referencing the v3 of the Google Maps API with the above URL - see here in their documentation.

First question: This was answered by #staypuftman.
Second question: You may save a local copy of a part of google maps using Google Static Maps which will return a value as an image file.

Related

Resolve Google maps link into address using JavaScript

I have a Google Sheet with column in which there is links to google maps like this:
http://goo.gl/maps/1FBvx
And I want to turn it into addresses like "м. Київ, вул. Олександра Довженко 1А".
I already know how to write custom functions for sheets in javascript. Now I want to know if it is possible to call Google Maps API functions from there, and what function to search for.
Of if there is a way to do it with CSV using some scripting language like Python - also good.

Is there a way to add a Javascript-based Signature Pad to a Google Form to capture a responder's signature?

Is there a way to add in Thomas Bradley's Signature Pad plugin so that someone who is filling out the Google Form would be able to sign the form? Would it be possible to use the HTML Service option to create a custom HTML form web app that can then still upload the responses into a Google Spreadsheet?
The project I've been asked to look into involves an individual being able to fill out a form but they would also like to be able to capture a signature (essentially a web form replacing paper forms) and they would like to do it all with Google since it is their preferred service. They also prefer to use Google Spreadsheets.
I'm very new to Google App Scripts and have a beginner's understanding of Javascript so I may very well misunderstand the uses and potential of Google App Scripts. Any help or advice is much appreciated.
patt0 is right. Here is a working example...
I've added a jQuery signature pad plugin to a Google spreadsheet using Google's HTML Service. (http://willowsystems.github.io/jSignature/#/about/)
The following example shows a signature pad on a Google Spreadsheet and converts the drawn signature to Base64 vector (image/jSignature;base30) data.
Here is my code.gs :
var ss = SpreadsheetApp.getActive();
function openDialog() {
var html = HtmlService.createHtmlOutputFromFile('index');
ss.show(html);
}
and here is index.html - - (link in your own Jsignature.js):
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="jSignature.js></script>
<script>
$(document).ready(function() {
$("#signature1").jSignature();
});
</script>
<div id="signature1"></div>
<button type="button" onclick="$('#signature1').jSignature('clear')">Clear</button>
<button type="button" onclick="alert($('#signature1').jSignature('getData','base30'))">Export</button>
As far as I can see, adding the plugin to a Google Form directly will not be possible.
Using HTML Service is a good idea and yes indeed it will be possible to get the the data from the form and push it to a spreadsheet, which then can trigger other workflow parts.
The only potential red flag is to find out wether the dependencies for the plugin are compatible HTML Service (https://developers.google.com/apps-script/guides/html-service-caja).
Let me know if you need more direction.

How do I get traffic control for my Google Map object?

I have set my Google Map object to view as a ROADMAP, but there is no traffic options like there is on the regular Google Maps. Below is the control I am trying to get. Is this possible via the map options in the API? I tried looking in the docs but there is nothing there for that (unless I am missing something).
You can create a custom control as shown on this example from the documentation.
Here is an example that shows embedding a traffic control onto the map.
http://pietervogelaar.nl/google-maps-api-v3-traffic-toggle-button/

calling one javascript from another one

I have got a question. Is that possible to call a javascript from another one. If it is, can anyone tell me how to do that?
What I want to achieve is basically:
I have got a php page. I do not want to put all the code here. It contains google map api js. I have written classes like Marker and MarkerManager. I want to keep them in another javascript file so I can call them from php.
To do this, I need to call google map api js from the js I have written which includes Marker and Manager class.
mytest.js (call google map api js)
Marker
MarkerManager
main.php (call mytest.js)
I hope this explains what I want to do.
Thanks in advance.
Simply include your file after the map js file and you should be fine.
Just include multiple script files in your page in whatever order they need to be run:
<script type="text/javascript" src="mytest.js"></script>
<script type="text/javascript" src="xxxxx.js"></script>

How can I access the version number of the Google Maps API in Javascript?

Does the Google Maps Javascript API have a property/method that returns its exact version number?
I need this info for debugging purposes.
To acccess exact version of Google Maps API one can check google.maps.version
When you include Google Maps API you can choose version of it. Example:
<script type="text/javascript" src="http://www.google.com/jsapi?key=LONG_KEY_HERE"></script>
<script type="text/javascript">
/*<![CDATA[*/
google.load('maps', '2');
/*]]>*/
</script>
Here we want to use version 2 of Google Maps API.
I suppose the G_API_VERSION could do :
This constant specifies the version of
the API currently being served to your
page.
I've just tested on two sites, and it contained things like "193c" and "140g".
In the Maps API v2, G_API_VERSION is what you want. For example, 193c means its loading v2.193c, 140g means 2.140g.
Changelog is here: http://code.google.com/p/gmaps-api-issues/wiki/JavascriptMapsAPIChangelog

Categories