我正在尝试使用Google数据层显示一些公交路线,然后添加一些自定义图标标记.适用于Chrome和Firefox,但在IE 11中我只能获得路线.我在一些混淆的代码深处得到一个InvalidStateError.
标记使用带有内联SVG的数据uri,该SVG转换为base 64字符串.我也尝试过不转换为base 64; 这不会产生任何明显的错误,但标记仍然不会显示.
下面粘贴了简化的javascript,你可以在jsfiddle中看到它.
var map;
map = new google.maps.Map(document.getElementById('map-canvas'), {
zoom: 11,
center: {lat: 38.813605, lng: -89.957399}
});
var geoJsonRoutesUrl = 'https://storage.googleapis.com/gtfs-test/MCT-All-Bus-Routes.json';
var routesLayer = new google.maps.Data();
routesLayer.loadGeoJson(geoJsonRoutesUrl);
routesLayer.setMap(map);
routesLayer.setStyle(function(feature) {
return ({
strokeColor: feature.getProperty('color'),
fillColor: feature.getProperty('color'),
strokeWeight: 6
});
});
var geoJsonRouteMarkersUrl = 'https://storage.googleapis.com/gtfs-test/MCT-All-Bus-Route-Markers.json';
var routeMarkersLayer = new google.maps.Data();
routeMarkersLayer.loadGeoJson(geoJsonRouteMarkersUrl);
routeMarkersLayer.setMap(map);
routeMarkersLayer.setStyle(function(feature) {
var markerIcon = CreateRouteMarkersIconDefinition(
feature.getProperty('route'),
feature.getProperty('color'),
feature.getProperty('backColor'));
return ({icon: markerIcon});
});
function CreateRouteMarkersIconDefinition(route, color, backColor) { …
Run Code Online (Sandbox Code Playgroud) 我有一个 Product 表和一个 AccountingPeriod 表,具有从 Product.manufacturingPeriodId 到 AccountingPeriod.id 的belongsTo关系。
下面的代码可以编译,但会因“模型产品上的属性‘manufacturingPeriod’和关联‘manufacturingPeriod’之间的命名冲突而崩溃。要解决此问题,请在运行时更改foreignKey或如关联定义中的那样”。
如果我as
按照指示更改最底部的关联代码,我也会爆炸,但这次“AccountingPeriod 使用别名与产品关联。您已包含别名 (accountingPeriod),但它与别名不匹配”在您的协会中定义”。第二条错误消息特别令人费解,因为我没有指定名为accountingPeriod的别名。
哎哟!对我来说似乎是第 22 条军规。
当然,我可以在调用sequelize.define()时ProductAttributes.manufacturingPeriod
删除、放回manufacturingPeriodId: number;
并重命名manufacturingPeriod
回选项对象中。manufacturingPeriodId
编译和运行得很好,但我无法编写类似myproduct.manufacturingPeriod.startDate
打字稿的代码。
我尝试过各种其他方法。一切都失败了,所以我举白旗投降。谁能帮我吗?我对续集有经验,但对打字稿相对较新,我只是没有看到它。
import * as Sequelize from 'sequelize';
import {ObjectRelationalManager as orm} from '../index';
import {AccountingPeriodInstance} from './accounting-period';
export interface ProductAttributes {
id?: number;
name: string;
manufacturingPeriod: AccountingPeriodInstance;
}
export interface ProductInstance extends Sequelize.Instance<ProductAttributes>, ProductAttributes {}
export default (
sequelize: Sequelize.Sequelize,
dataTypes: Sequelize.DataTypes …
Run Code Online (Sandbox Code Playgroud) 我一直在阅读Block-Element-Modifier命名约定,语义命名的样式规则等等.我想用一个单一的语义类名替换我的html中的多个类名.但是,似乎无法实现.例:
我想替换我的Bootstrap导航栏
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
同
<nav class="header__navbar" role="navigation">
我知道我可以使用jQuery在程序上执行此操作,但我不想这样做.我尝试了几种使用变量名称的方法,#{}插值语法,mixins和@extend等,但只是得到语法错误或无效结果.
这不是Sass的目的吗?
过去,当来自DefinitelyTyped的类型声明落后于底层javascript 库时,我曾成功地使用打字稿“模块扩充”作为临时解决方法 。但是,类型定义始终包含在单个文件中,并且我正在使用的特定公共库的新版本通过重新导出等将定义分解为多个模块。
过去这会奏效,但现在不行:
import * as Sequelize from 'sequelize';
declare module 'sequelize' {
interface HasManyOptions {
sourceKey?: string;
}
Run Code Online (Sandbox Code Playgroud)
那么如何使用下面的文件结构将 add sourceKey添加到HasManyOptions接口?我试过弄乱导入模块的名称和嵌套模块声明,但没有爱。我难住了。
索引.d.ts
export * from './lib/sequelize'
Run Code Online (Sandbox Code Playgroud)
./lib/sequelize.d.ts
export * from './associations/index'
Run Code Online (Sandbox Code Playgroud)
./lib/associations/index.d.ts
export * from './has-many'
Run Code Online (Sandbox Code Playgroud)
./lib/associations/has-many.d.ts
export interface HasManyOptions extends ManyToManyOptions {
keyType?: DataType
...
}
Run Code Online (Sandbox Code Playgroud) 我们正在使用Web API和OWIN创建我们自己的身份验证和授权提供程序。一切都很好,但是现在我们的任务是允许CORS请求。
CorsHttpConfigurationExtensions
为我们的api工作,我们还使用来处理了令牌请求CorsExtensions
。事情是这样的:这条线
app.UseCors(CorsOptions.AllowAll);
Run Code Online (Sandbox Code Playgroud)
in Startup.ConfigureAuth()
允许所有来源,标头项目和方法,不是吗?相当于
config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
Run Code Online (Sandbox Code Playgroud)
在WebApiConfig.Configure()
-对吗?只有一个枚举值AllowAll
的CorsOptions
。而且没有地方用任何种类的属性来装饰令牌路由。
我不太在意标题和动词(方法)。大概是OWIN程序集正在处理这些内容,例如仅限于POST。但是我们真的很想将原始标头限制在特定的域中。有谁知道我们如何做到这一点?