谷歌融合表的PieChart / Listener事件(PieChart / Listener event of a google fusion table)
我有一个包含两列的融合表('TOTAL_ROOF'和'POTENTIAL_')。 'POTENTIAL_'是'TOTAL_ROOF'的子集。
现在我是:
1)显示由用户“点击”确定的格式化行数据
2)尝试绘制一个PieChart即:drawVisualization.PieChart(e.row ['TOTAL_ROOF',“POTENTIAL _']。value);
我已经获得了#1的工作......然而,对于#2我有点迷失了...我看到的所有例子都显示PieChart已经被用户点击任何东西之前已经创建了。
有没有办法在点击后创建PieChart? 将空间留空(直到#1)?
另外,我没有看到如何在我的文本框中调用它(例如: http : //jsfiddle.net/fG5a5/1/ )。
这是我到目前为止的代码:
加载库:
google.load('maps', '3.5', {other_params:'sensor=false'}); google.load('jquery', '1.6.0'); google.load('visualization', '1', {packages:["corechart"]}); google.load('jqueryui', '1.8.12');
JS
var tableid = 1DGswslbC5ijqWHPJvOH1NH7vltkZIPURJun_L5I; var location_column = 'geometry' function drawVisualization() { google.visualization.drawChart({ "chartType": "PieChart" })}; // Draw Visualization of WHAT (the event listener has not been triggered??) function initialize() { google.maps.event.addListener(layer, 'click', function(e) { $("#roof-panel-area").html( '<p><strong>Total Roof Area (sqft)</strong>: ' + ' ' + Math.round(e.row['TOTAL_ROOF'].value) + '<br><strong> Potential Roof Area (sqft)</strong>:' + ' ' + Math.round(e.row['POTENTIAL_'].value) + '<br><strong> Pitched or Flat Roof (?)</strong>:'+ ' ' + e.row['PITCHED_OR'].value + '<br><strong> # of Panels per Roof Area :</strong>' + ' ' + Math.round(e.row['NUMBER_OF_'].value) + '</p>'); }); // Click Listener on layer using jquery , searches for fields related to // roof/panel, google.maps.event.addListener(layer, 'click', function(e) { drawVisualization.PieChart(e.row['TOTAL_ROOF','POTENTIAL_'].value); }); // Click Listener - updates graph layer.setMap(map); }
HTML:
<div id="sidebarItem"> <br> <h1> Hatfield Solar Map</h1> <!---Create a text box input for the user to enter the street address--> Address: <input type="text" id="inputTextAddress" style=" width:200px" title="Address to Geocode" /> <!--Create a button input for the user to click to geocode the address--> <input type="button" onclick="codeAddress()" id="inputButtonGeocode" style="width:200px" title="Click to Find Address" value="Click to Find Address" /> <h3>Select a building outline or search for an address to identify buildings that you'd like to select.</h3> <!---Content from Click--> <hr/> <div id="sidebar-content-area" style="padding:5px;"> <div id="intro" style="text-align: center; margin-top: 20px; display: none;"> <p><i>Buildings are symbolized according to roof size, and the possibility of increased panel placement.</i><p> </div> <div id="overview" style:""> <h3>Building Overview:</h3> <p id ="roof-panel-area"></p> </div> </div>
I have a fusion table with two columns ('TOTAL_ROOF' & 'POTENTIAL_'). 'POTENTIAL_' is a subset of 'TOTAL_ROOF'.
Right now I am:
1) Showing formated row data determined by the users 'click'
2) trying to draw a PieChart i.e.: drawVisualization.PieChart(e.row['TOTAL_ROOF', "POTENTIAL_'].value);
I've gotten #1 to work... However, for #2 I am a bit lost on what to do...all the examples I see show the PieChart already being created BEFORE the user has clicked anything.
Is there a way to create the PieChart after the click? Leaving the space blank until (like it is for #1)?
Also I don't see how to call it in a into my text-box (ex: http://jsfiddle.net/fG5a5/1/).
Here is my code so far:
load libraries:
google.load('maps', '3.5', {other_params:'sensor=false'}); google.load('jquery', '1.6.0'); google.load('visualization', '1', {packages:["corechart"]}); google.load('jqueryui', '1.8.12');
js
var tableid = 1DGswslbC5ijqWHPJvOH1NH7vltkZIPURJun_L5I; var location_column = 'geometry' function drawVisualization() { google.visualization.drawChart({ "chartType": "PieChart" })}; // Draw Visualization of WHAT (the event listener has not been triggered??) function initialize() { google.maps.event.addListener(layer, 'click', function(e) { $("#roof-panel-area").html( '<p><strong>Total Roof Area (sqft)</strong>: ' + ' ' + Math.round(e.row['TOTAL_ROOF'].value) + '<br><strong> Potential Roof Area (sqft)</strong>:' + ' ' + Math.round(e.row['POTENTIAL_'].value) + '<br><strong> Pitched or Flat Roof (?)</strong>:'+ ' ' + e.row['PITCHED_OR'].value + '<br><strong> # of Panels per Roof Area :</strong>' + ' ' + Math.round(e.row['NUMBER_OF_'].value) + '</p>'); }); // Click Listener on layer using jquery , searches for fields related to // roof/panel, google.maps.event.addListener(layer, 'click', function(e) { drawVisualization.PieChart(e.row['TOTAL_ROOF','POTENTIAL_'].value); }); // Click Listener - updates graph layer.setMap(map); }
html:
<div id="sidebarItem"> <br> <h1> Hatfield Solar Map</h1> <!---Create a text box input for the user to enter the street address--> Address: <input type="text" id="inputTextAddress" style=" width:200px" title="Address to Geocode" /> <!--Create a button input for the user to click to geocode the address--> <input type="button" onclick="codeAddress()" id="inputButtonGeocode" style="width:200px" title="Click to Find Address" value="Click to Find Address" /> <h3>Select a building outline or search for an address to identify buildings that you'd like to select.</h3> <!---Content from Click--> <hr/> <div id="sidebar-content-area" style="padding:5px;"> <div id="intro" style="text-align: center; margin-top: 20px; display: none;"> <p><i>Buildings are symbolized according to roof size, and the possibility of increased panel placement.</i><p> </div> <div id="overview" style:""> <h3>Building Overview:</h3> <p id ="roof-panel-area"></p> </div> </div>
原文:https://stackoverflow.com/questions/16270726
最满意答案
要捕获命令的输出,请使用
for /f
循环。 有关更多信息,请参阅help for
。练习1
要将
%var%
的值设置为findstr
的输出,请执行以下操作:for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I"
然后,如果你想要该行的最后一个单词,你可以使用一个基本的
for
循环来循环遍历%var%
每个单词。for %%I in (%var%) do set "lastword=%%I" set "var=%lastword%"
练习2
或者,如果你知道包含“name”的行总是4个令牌长(例如,“我的名字是等等”),你可以像这样简单地捕获
findstr
输出的第四个标记。for /f "tokens=4" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I"
就是这样。
%var%
将包含findstr
匹配的第四个单词。
练习3
如果您知道该行将始终以“我的名字是”开头,但您想要名字的可能性,或许多名称如“John Jacob Jingleheimer-Schmidt”,您可以使用
tokens
来捕获您想要的类似内容练习2。for /f "tokens=3*" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%J"
请注意,这次我捕获了
%%J
而不是%%I
那是因为%%I
将是令牌3(第三个单词),而%%J
就是其后的一切(tokens=3*
的通配符tokens=3*
)。
练习4
或者,如果名称可能是名字和姓氏,但您知道它的前面是“我的名字是”,您可以通过变量子字符串替换删除“我的名字是”部分。
for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I" set "var=%var:My name is =%"
这将从
%var%
的值中删除“我的名字是”,留下你的“约翰史密斯”。
练习5
如果你不能指望包含“name”的行是相同数量的单词(例如,“你好!我的名字是”或“你好!我的名字是”,你可以使用带有通配符的变量子串替换剥离变量内容。无论名称是一个字还是更多,无论“名称”之前的内容是否有所不同,这都应该有效。
for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I" set "var=%var:*name is =%"
To capture the output of a command, use a
for /f
loop. Seehelp for
for more information.Exercise 1
To set the value of
%var%
to the output offindstr
, do it something like this:for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I"
Then if you want the last word of the line, you can use a basic
for
loop to loop through each word of%var%
.for %%I in (%var%) do set "lastword=%%I" set "var=%lastword%"
Exercise 2
Alternatively, if you know that the line containing "name" will always be 4 tokens long (as in, "My name is blah"), you can simply capture the fourth token of the output of
findstr
like this.for /f "tokens=4" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I"
And that's it.
%var%
will contain the fourth word of the line matched byfindstr
.
Exercise 3
If you know that the line will always begin with "My name is" but you want the possibility of a first and last name, or lots of names like "John Jacob Jingleheimer-Schmidt", you can use
tokens
to capture what you want similar to Exercise 2.for /f "tokens=3*" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%J"
Notice that I captured
%%J
instead of%%I
this time. That's because%%I
would be token 3 (the third word), while%%J
is everything thereafter (the wildcard intokens=3*
).
Exercise 4
Or if it's possible that the name could be a first and last name, but you know it will be preceded by "My name is", you can remove the "My name is" part via variable substring substitution.
for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I" set "var=%var:My name is =%"
which will strip "My Name is " from the value of
%var%
, leaving you with "John Smith".
Exercise 5
If you can't count on the line containing "name" to be the same number of words (for instance, "Hi there! My name is" or "Hello! My name is", you can use variable substring substitution with a wildcard to strip out variable content. This should work regardless of whether the name is one word or more, and regardless of whether the content before "name is" varies.
for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I" set "var=%var:*name is =%"
相关问答
更多-
你错过了什么;-) cmd在命令解析时展开变量,而不是在运行时展开。 恰巧在这种情况下,具有块( ... ) (或实际上任何块)的if或for语句作为单个命令发挥作用。 所以,当你在一个块中设置变量, 并尝试在同一个块中使用它们时,不再有变量 - 它们被变量在块执行之前所具有的值替换。 坚持一下 setlocal enabledelayedexpansion 在批处理文件的开始处使用!zip! 而不是%zip% 。 请参阅help set以便详细讨论问题。 You missed something ;-) ...
-
批处理脚本问题 - 在变量中搜索并替换变量?(Batch Scripting Question - Search and Replace a Variable in a Variable?)[2022-06-18]
打开延迟扩展 setlocal enabledelayedexpansion 并使用 set upath2=!cd:%userprofile%=~! 请注意, setlocal将启动一个新的变量作用域,并且在该作用域内对环境变量所做的任何更改都不会在其之外持续存在。 但是,您可以执行以下操作以进行一次性使用: setlocal enabledelayedexpansion set upath2=!cd:%userprofile%=~! endlocal&set upath2=%upath2% Turn ... -
批处理脚本冒险(Batch Scripting Adventure)[2021-05-18]
ELSE应与IF关键字位于同一行,或者与IF的右括号位于同一行。 喜欢这个: IF %TypeName% == "abcd" GOTO correctName ELSE GOTO wrongName 或者像这样: IF %TypeName% == "abcd" ( ECHO Correct. GOTO correctName ) ELSE GOTO wrongName Equal运算符的正确关键字是EQU : IF %TypeName% EQU "abcd" GOTO correctName ... -
如何在不同的变量中设置多行命令输出?(How to set multiple line command output in different variables? (Batch))[2022-01-06]
你不需要文件: @echo off setlocal enabledelayedexpansion set i=0 for /f "tokens=2 delims=:=" %%a in ('wmic logicaldisk get name /value ') do ( set /a i+=1 set drive[!i!]=%%a ) set drive 如果您需要冒号,只需将其添加到set drive[!i!]=%%a:我将其删除(作为几种方法之一)以消除不寻常的wmic行结尾) you don ... -
批处理 - 如何在脚本中读取另一个命令行函数的输出?(Batch - How do I read the output of another command line function in a script?)[2022-04-23]
我将首先回答你的实际问题,但这些建议可能对你正试图解决的任何潜在问题有用: 您可以让phpunit日志结果更容易让机器读取。 PHP是编写命令行脚本的BASH的有效替代品。 我使用BASH来做简单的事情,但是一旦它超出了几行,或者当我想添加循环,if语句等时,我决定在PHP中正确执行它。 其他人可能达到perl或python。 在你的特定情况下,我会用PHP而不是BASH来做,因为它可能最终需要一些复杂的解析。 但让我们看看在BASH中如何做一些简单的事情。 挑战是输出可能看起来像这样: PHPUnit 3 ... -
for / f批处理脚本(for /f in batch scripting)[2022-03-28]
得到它..而不是('%DATE%')应该是(`date / t`) Got it.. Instead of ('%DATE%') should be (`date /t`) -
如何在jenkins的窗口中使用batch命令输出设置变量值(How to set a variable value using batch command output on windows in jenkins)[2022-10-03]
由于每个Execute Window Batch或Execute shell构建步骤都在单独的沙箱中运行,因此任何环境变量导出到它们内部都将一步完成。 如果您希望跨环境使用这些环境varabiles,则必须先导出到文件中,然后再读取文件。 步骤1 ,通过Execute window batch或'Execute shell'生成一个具有key = value模式的纯文件, 第2步 ,添加一个Inject environment variable构建步骤,并指定上面生成的文件,一旦这个构建步骤完成,这些键将被 ... -
要捕获命令的输出,请使用for /f循环。 有关更多信息,请参阅help for 。 练习1 要将%var%的值设置为findstr的输出,请执行以下操作: for /f "delims=" %%I in ('findstr /i "name" "temp.txt"') do set "var=%%I" 然后,如果你想要该行的最后一个单词,你可以使用一个基本的for循环来循环遍历%var%每个单词。 for %%I in (%var%) do set "lastword=%%I" set "var=%la ...
-
命令FOR with选项/F以及命令或命令行( set括在括号内的字符串)可以用于在一行中处理一个命令或命令行输出的多个命令。 你可以使用这个批处理文件: @ECHO OFF SET "_process=cmd.exe" FOR /F %%I IN ('%SystemRoot%\System32\tasklist.exe /FI "IMAGENAME eq %_process%" ^| %SystemRoot%\System32\find.exe /I /C "%_process%"') DO SET "_ ...
-
现在我知道了,会发生什么: compare -metric NCC "a.jpg" "b.jpg" "c.jpg" 2>> "result.txt" 您想要的输出是STDERR,而不是STDOUT(非常不寻常)。 但是仅for捕获STDOUT。 应该可以对for构造进行调整,但使用起来更简单:
> "result.txt" REM this line writes a string without linefeed compare -metric NCC " ...