如何使用OpenLayers-3将SVG图像用作图层(而不是地图标记)
使用任何ol.source.Vector和ol.format.Feature实例时,我无法获得任何SVG图像输出.
小例子:
var mapLayer = new ol.layer.Vector({
source: new ol.source.Vector({
url: 'image.svg',
format: new ol.format.Feature() // http://openlayers.org/en/v3.12.1/apidoc/ol.format.Feature.html
}),
});
Run Code Online (Sandbox Code Playgroud)
我在使用ImageStatic图层时能够获得输出,但这会使用/生成(?)静态图像,因此SVG的优势消失了.
例:
// Not sure if I need this for SVG, but is is required for an image
var extent = [0, 0, 1000, 1000]; // random image size
var projection = new ol.proj.Projection({
code: 'test',
units: 'pixels',
extent: extent
});
var mapLayer = new ol.layer.Image({
source: new ol.source.ImageStatic({
url: 'image.svg',
projection: projection,
imageExtent: extent
}) …Run Code Online (Sandbox Code Playgroud) 我有一个奇怪的问题,PDO在插入重复值时不会抛出异常.在这种情况下,我确实预计会出错.
相关代码:
try
{
$db_conn = new PDO("mysql:host=".$config["database"]["hostname"].";charset=utf8", $config["database"]["username"], $config["database"]["password"], []);
$db_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db_conn->exec(file_get_contents("some_file_with_data.sql");
}
catch(Exception $e)
{
// PDOException extends RuntimeException extends Exception so exceptions should be catched here
// however for the duplicate key entry it will not throw an exception
}
Run Code Online (Sandbox Code Playgroud)
带有SQL数据的文件包含多个这样的插入:
INSERT INTO `a` (`b`, `c`) VALUES
(1, 1),
(2, 2),
(3, 2);
INSERT INTO `a` (`b`, `c`) VALUES
(1, 1);
Run Code Online (Sandbox Code Playgroud)
b表中的字段a设置为主键.当我使用phpMyAdmin在完全相同的结构中插入完全相同的数据时,我收到此错误:#1062 - Duplicate entry '65533' for key 'PRIMARY'
为什么PDO在这种情况下不会抛出错误?即使我将错误模式设置为异常?
编辑:这是用于此特定表的表结构
CREATE …Run Code Online (Sandbox Code Playgroud) 似乎有之间的差异PDO::exec和PDO::query其时PDO::ATTR_PERSISTENT = true。使用PDO::exec连接时将不会被重用,最终导致 MySQL 出现“多连接”错误,因为它们似乎没有被关闭(或重用)。
例如,请参阅此小代码片段:
<?php
$pdo_attr = [
PDO::ATTR_PERSISTENT => true,
];
$pdo = new PDO("mysql:host=mysql;dbname=empty", "root", "iamreallysecure", $pdo_attr);
// The following will give a to many connections error after a few browser refreshes (connection limit is set to 10)
var_dump($pdo->exec("SELECT 1"));
// While the following does NOT leave >10 connections open and continues to work
//var_dump($pdo->query("SELECT 1")->fetchAll());
Run Code Online (Sandbox Code Playgroud)
该exec会留下“沉睡”的MySQL查询系统(带观察SHOW PROCESSLIST),而query不会触发此。
这是预期的吗?在这种情况下 exec 和 query …
我正在使用jQuery UI地图库(https://code.google.com/p/jquery-ui-map/)在我的html5移动网站上显示地图,但是我只会得到一个灰色的正方形我尝试了什么.
我的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>test</title>
<link rel="stylesheet" href="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.css">
<script src="https://d10ajoocuyu32n.cloudfront.net/jquery-1.9.1.min.js"></script>
<script src="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
<script type="text/javascript" src="https://local url/js/jquery-ui.js"></script>
<script type="text/javascript" src="https://local url/js/jquery.ui.map.full.min.js"></script>
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=true"></script>
</head>
<body>
<div data-role="page" id="main">
<div data-role="content">
<p>
TEST SITE
</p>
<p>
<canvas id="map_canvas" style="width:50%;height:50%"></canvas>
</p>
</div>
</div>
<script>
$(document).ready(function()
{
$('#map_canvas').gmap();
$('#map_canvas').gmap({ 'center': '42.345573,-71.098326' });
$('#map_canvas').gmap({ 'zoom': 8 });
$('#map_canvas').gmap('refresh');
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我得到的结果是这样的:
http://upload.mattie-systems.nl/uploads/28217-knipsel.png
任何帮助都会非常感激!