How can I change the language? I mean how to write city names (origin,destination) in Persian? like this: destination = "تهران، ایران"
Below code works correctly:
<script src="http://maps.google.com/maps/api/js?sensor=true&language=fa"></script>
<script type="text/javascript">
var origin = "Karaj",
destination = "Tehran",
service = new google.maps.DistanceMatrixService();
But I want Persian names:
<script src="http://maps.google.com/maps/api/js?sensor=true&language=fa"></script>
<script type="text/javascript">
var origin = "کرج",
destination = "تهران",
service = new google.maps.DistanceMatrixService();
This doesn't work. What should I do?
Use a suitable encoding for the page(usually UTF-8)
http://jsfiddle.net/doktormolle/9fsjM/
Related
How to exclude development sessions from Clarity recordings? I couldn't find any options in their settings.
Also, is it possible to restrict session recordings to certain countries?
The easiest way is to not include the script on localhost with a simple check on the current hostname:
if (!window.location.host.includes('localhost')) {
// code
}
Full snippet like this:
<script type="text/javascript">
if (!window.location.host.includes('localhost')) {
(function (c, l, a, r, i, t, y) {
if(window.location.host.includes('localhost'))
c[a] = c[a] || function () { (c[a].q = c[a].q || []).push(arguments) };
t = l.createElement(r); t.async = 1; t.src = "https://www.clarity.ms/tag/" + i;
y = l.getElementsByTagName(r)[0]; y.parentNode.insertBefore(t, y);
})(window, document, "clarity", "script", "XXXXXXX");
}
</script>
(Replace XXXXX with your key/code from clarity)
I have since switched to using Google Tag Manager for managing all the tags. GTM has an option to fire a tag based on hostname pattern match. I have set all tags to fire on production host only.
I want to quickly change the ouput format of web2py´s datepicker used in datetime or date fields in forms - or completely disable it. Where can I do this?
Look for the file ´web2py_ajax.html´
<script type="text/javascript"><!--
// These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below).
var w2p_ajax_confirm_message = "{{=T('Are you sure you want to delete this object?')}}";
var w2p_ajax_disable_with_message = "{{=T('Working...')}}";
var w2p_ajax_date_format = "{{=T('%d.%m.%Y')}}";
var w2p_ajax_datetime_format = "{{=T('%Y-%m-%d %H:%M:%S')}}";
var ajax_error_500 = '{{=T.M('An error occured, please [[reload %s]] the page') % URL(args=request.args, vars=request.get_vars) }}'
//--></script>
{{
response.files.insert(0,URL('static','js/jquery.js'))
response.files.insert(1,URL('static','css/calendar.css'))
response.files.insert(2,URL('static','js/calendar.js'))
response.files.insert(3,URL('static','js/web2py.js'))
response.include_meta()
response.include_files()
}}
Change var w2p_ajax_date_format for a different date format or edit the response.files-lines.
I am trying to apply a segment for a query through Google Analytics .NET client but I am not able to get it working. Here is what I have been trying:
var segments = analyticsService.Management.Segments.List().Execute();
var engagedTeamsSegment = segments.Items.FirstOrDefault(x => x.Name.Equals("Engaged Teams", StringComparison.OrdinalIgnoreCase));
var format = "yyyy-MM-dd";
var today = DateTime.UtcNow.Date;
var thirtyDaysAgo = today.Subtract(TimeSpan.FromDays(30));
var metrics = engagedTeamsSegment.Definition.Replace(';', ',');
var gaData = analyticsService
.Data.Ga
.Get($"ga:{profile.Id}", today.ToString(format), thirtyDaysAgo.ToString(format), metrics)
.Execute();
It's getting me the below error
An unhandled exception of type 'Google.GoogleApiException' occurred in
Google.Apis.dll
Additional information: Google.Apis.Requests.RequestError
Invalid value
'users::condition::ga:dimension2!=0,ga:sessionCount>=2,ga:daysSinceLastSession<=14'.
Values must match the following regular expression: 'ga:.+' [400]
Errors [
Message[Invalid value
'users::condition::ga:dimension2!=0,ga:sessionCount>=2,ga:daysSinceLastSession<=14'.
Values must match the following regular expression: 'ga:.+']
Location[metrics - parameter] Reason[invalidParameter] Domain[global]
]
I am probably doing something wrong but not sure what. Any ideas?
Found the solution thanks to this question. There was a Segment parameter on the request. Below code did the trick:
var segments = analyticsService.Management.Segments.List().Execute();
var engagedTeamsSegment = segments.Items.FirstOrDefault(x => x.Name.Equals("Engaged Teams", StringComparison.OrdinalIgnoreCase));
var format = "yyyy-MM-dd";
var today = DateTime.UtcNow.Date;
var thirtyDaysAgo = today.Subtract(TimeSpan.FromDays(30));
var gaDataRequest = analyticsService
.Data.Ga
.Get($"ga:{profile.Id}", thirtyDaysAgo.ToString(format), today.ToString(format), "ga:users");
gaDataRequest.Segment = engagedTeamsSegment.Definition;
var gaData = gaDataRequest.Execute();
I am trying to reproduce something that I have created in Google Earth/KML but have problems in Google Maps due to my inexperience with JS.
I want to load around 1000 markers using lat, long, size and color data from XLS.
I have seen an example of how to control market position and size using data from a JSON source,
I have also seen an example of an import from XLS to a JS array.
In the XLS file the data is in columns: Lat, Long, Size, Color and Label. The color can be expressed in CSS. The label would be the basis of a tooltip.
Any suggestions welcome.
Many thanks
Steve
I have done this several times. There are a few options...
Have a look at Google Fusion Tables - these are really easy to use and lightning fast - able to deal with 500,000 points.
For 1,000 points, I would export the Excel data to a CSV file, then convert the CSV to a Javacript array, and embed the array and some Javascript into your webpage. I am providing a Perl script that will convert the CSV you get out of Excel into a Javascript array - it may not be perfect but you will get the idea. Then I am providing some Javascript that creates the markers, which may also not be perfect, but you will get the idea.
So, this converts a CSV file into Javascript array:
#!/usr/bin/perl
use strict;
use warnings;
my $printcomma=0;
print "var Points = new Array(\n";
while (<>) {
# Trim end of line character
chomp;
my $line = $_;
# Define variables to hold each CSV field
my ($lat,$lon,$size,$color,$label) = split (',',$line);
print ",\n" if $printcomma;
print "{lat:'$lat',lon:'$lon',size:'$size',color:'$color',label:'$label'}";
$printcomma = 1;
END
}
print ");\n";
You save it as "csv2js", then you go to a Terminal and type:
chmod +x csv2js
./csv2js < yourCSVfile > points.js
Assuming your CSV file looks something like this:
53.1,0.002,100,255,Some label
52.7,0.011,1000,200,Another label
55.89,-0.78,10000,128,Yet another label
it will create a file that looks something like this:
var Points = new Array(
{lat:'53.1',lon:'0.002',size:'100',color:'255',label:'Some label'},
{lat:'52.7',lon:'0.011',size:'1000',color:'200',label:'Another label'},
{lat:'55.89',lon:'-0.78',size:'10000',color:'128',label:'Yet another label'});
Then you inclue the file created above (points.js) into the top of the following file and use that as the basis of your HTML webpage:
<HTML>
<head>
<!-- Pull in Javascript version of Excel CSV -->
<script src="points.js"></script>
<!-- A bunch of your own stuff -->
<script type="text/javascript">
////////////////////////////////////////////////////////////////////////////////
// This function is called dynamically to build the Infowindow as it pops up as
// a result of the user clicking a pin on the map.
////////////////////////////////////////////////////////////////////////////////
function DeriveInfowindowContent(i){
// Build the wording for the pop-up Infowindow, one piece at a time;
var t1 = "<h4>" + Points[i].label + "</h4>";
return t1;
}
////////////////////////////////////////////////////////////////////////////////
// Function called when webpage first loads
////////////////////////////////////////////////////////////////////////////////
function initialize() {
////////////////////////////////////////////////////////////////////////////////
// Next line sets the latitude/longitude of map centre at startup. Use tools at
// http://www.getlatlon.com to find a nice, new map centre's coordinates.
////////////////////////////////////////////////////////////////////////////////
var myMapCentre = new google.maps.LatLng(51.50,-0.135);
////////////////////////////////////////////////////////////////////////////////
// "zoom" sets the zoom (or scale) of the map
// Use any value between 0-20, 12 seems about right to me.
// Smaller numbers mean you see a larger area of ground in your browser.
////////////////////////////////////////////////////////////////////////////////
var myOptions = {
zoom: 12,
center: myMapCentre,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
gmap = map; // Store in global var gmap
// Just use one Infowindow and set its content each time before use, this
// saves memory and means old infowindow closes when user opens a new one.
var Infowindow = new google.maps.InfoWindow();
// Go through plotting all points on map
for(var i=0;i<Points.length;i++){
Points[i].LatLon = new google.maps.LatLng(Points[i].lat,Points[i].lon);
Points[i].Marker = new google.maps.Marker({position:Points[i].LatLon,map:map});
Points[i].Marker.index = i;
google.maps.event.addListener(Points[i].Marker, 'click', function() {
var s=DeriveInfowindowContent(this.index);
Infowindow.setContent(s);
Infowindow.open(map,this);});
}
}
</script>
</head>
<body onload="initialize()">
Note that this code doesn't do anything with the "color" or the "size" parameters in your Excel spreadsheet, but I guess you can work those bits out yourself now you have a basic structure.
UPDATE: Since doing this I have found a nice Javascript library that will parse your Excel-produced CSV file into an array for you, which means you won't need my Perl above. See Evan's answer to this question.
I want to add a label in flex to display m/s2 (read meters per second square). I would need to use superscripting for this.
I have tried out the following code which is giving me a compilation error.
var richtxt1:RichText = new RichText();
richtxt1.text="m/s";
var richtxt2:RichText = new RichText();
var span:SpanElement = new SpanElement();
span.text = "2";
span.baselineShift = "superscript";
richtxt2.addChild(span);
richtxt1.text=rixhtxt1.txt + richtxt2.text
I am getting a compilation error for the line richtxt2.addChild(span)
The error is
Implicit coercion of a value of type flashX.textLayout.elements.SpanElement
to unrelated type flash.Display.DisplayObject
I think you've to do something like this
var xmlText:String = "<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'>" +
"m/s <span baselineShift='superscript'>2</span>" +
"</TextFlow>";
var txtFlow:TextFlow = TextFlowUtil.importFromXML(xmlText);
var richTxt:RichText = new RichText();
richtxt.textFlow = txtFlow;
I've not tested it so please excuse me of any compilation errors.
This is the code I used in my iPad app to accomplish the above:
var xmlText:String = "m/s <span baselineShift='superscript'>2</span>";
var txtFlow:TextFlow = TextFlowUtil.importFromString(xmlText);
var richTxt:RichText = new RichText();
richTxt.textFlow = txtFlow;
this.addElement(richTxt);
It is based on kaychaks and information I found from Adobe's website. The differences are
I took out the TextFlow markup but left in the HTML;
importFromString rather than importFromXML; and
I added this.addElement(richText) to display the element.