有没有办法随机更改原生Leaflet中的标记颜色?我正在使用可以设计风格的svg元素.我知道mapbox.js是可行的
编辑:澄清我打算做什么:如果您通过双击或其他东西添加标记,它应该有随机颜色.为了实现这一点,我想使用标记的svg图标来设置它们的样式.
这是我的代码:
myIcon = L.icon({
iconUrl: "icon_33997.svg",
iconAnchor: pinAnchor
});
newMarker = L.marker(lat, long], {
icon: myIcon
});
Run Code Online (Sandbox Code Playgroud) 我正在测试新的Meteor build 0.9.2,它现在集成了Phonegap.到目前为止一切正常.但我真的不明白如何在我的Android设备上启动我的应用程序.手册指出您应该指定meteor run android-device -p <local IP>:<local port>
并且服务器和设备应该连接到同一本地网络.我在这里使用服务器的ip和端口.但我得到这个错误:
ERROR: Failed to launch application on device: ERROR: Failed to install apk to device: ERROR: Failed to deploy to device, no devices found.
我不确定如何将设备链接到服务器.
我在我的程序中调用了一个新阶段,我希望在按下escape时关闭.我这样做了,它给了我一个NullPointerException:
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent t) {
KeyCode key = t.getCode();
if (key == KeyCode.ESCAPE){
stage.close();
}
}
});
Run Code Online (Sandbox Code Playgroud) 我尝试了解如何在多线程环境中更新ProgressBar.我在这里做错了但我不知道它是什么.这应该只是每隔3秒填满一次吧,但它没有:
Task<Void> task = new Task<Void>(){
@Override
public Void call(){
for (int i = 1; i < 10; i++) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(i);
updateProgress(i , 10);
}
return null;
}
};
updProg = new ProgressBar();
updProg.progressProperty().bind(task.progressProperty());
Thread th = new Thread(task);
th.setDaemon(true);
th.start();
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
如何在TableView中设置选择?我想要默认选择第一个索引.
productTable.selectionModelProperty().set(value);
Run Code Online (Sandbox Code Playgroud)
这是正确的吗?应该value
是什么?
我正在尝试将一些ZPL代码发送到从Windows 7中的Java应用程序连接USB的Zebra TLP 2824.我尝试了不同的方法,但还是无法打印.在驱动程序设置中,我激活直通模式并尝试使用通用/文本模式驱动程序安装打印机,但没有任何效果.
我总是在打印队列中得到未指定的Windows错误.
这是我的代码:
try {
PrintService psZebra = null;
String sPrinterName = null;
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
for (int i = 0; i < services.length; i++) {
PrintServiceAttribute attr = services[i].getAttribute(PrinterName.class);
sPrinterName = ((PrinterName) attr).getValue();
if (sPrinterName.toLowerCase().indexOf("generic") >= 0) {
psZebra = services[i];
System.out.println(psZebra);
break;
}
}
if (psZebra == null) {
System.out.println("Zebra printer not found.");
return;
}
DocPrintJob job = psZebra.createPrintJob();
String s = "${^XA^FO100,100^BY7^BCN,100,Y,N,N^FD123456^FS^XZ}$";
byte[] by = s.getBytes();
DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
Doc doc …
Run Code Online (Sandbox Code Playgroud) 我想在传单地图上设置标记。为了实现这一点,我尝试了jquery-mobile-events并取得了小小的成功。这就是我集成它的方式:
$(map).off('taphold');
$(map).bind('taphold', function(e, options){
... do something ...
});
Run Code Online (Sandbox Code Playgroud)
它可以在桌面上运行,但不能在移动设备上运行。'map' 是一个 L.map 对象。与之相关的另一个问题是我无法获取 options.startPosition 和 options.endPosition。我需要这个来区分用于平移地图的长按和用于放置标记的长按。有谁知道这个问题的解决方案吗?
我试图检查一个字符串是否存在于一个相对较大的(比如8000项)字符串列表中.
这就是我做的:
for ( int i = 0; i < listOfStrings.size(); i++){
String trim = listOfStrings.get(i).getString().trim();
if (trim.equals(testString)){
check = true;
break;
} else {
check = false;
}
}
Run Code Online (Sandbox Code Playgroud)
但是虽然我确定字符串在列表中但我得到了错误的回报.对于大型列表,这是一种错误的方法吗?
编辑:
很抱歉没有上下文的代码被剪切了.是的,打破; 不见了.