无法读取未定义的、Terraformer.GeoStore、Terraformer.Store.Memory、Terraformer的属性'Memory‘,我收到错误:
Cannot read property 'Memory' of undefined
html:
// not work
<script src="https://unpkg.com/terraformer"></script>
<script src="https://unpkg.com/terraformer-geostore"></script>
<script src="https://unpkg.com/terraformer-rtree"></script>
<script src="https://unpkg.com/terraformer-geostore-memory"></script>
// not work
<script src="https://unpkg.com/terraformer@1.0.7"></script>
<script src="https://unpkg.com/terraformer-geostore@1.0.4/browser/terraformer-geostore.js"></script>
js: Cannot read property 'Memory' of undefined
// create a new GeoStore using Memory and an RTree Index
var store = new Terraformer.GeoStore({
store: new Terraformer.Store.Memory(), // error Cannot read property 'Memory' of undefined
index: new Terraformer.RTree()
});发布于 2019-11-23 05:25:12
单据编码错误!花我3个小时找出原因
见下图
store: new Terraformer.Store.Memory(),是错误的,
正确的代码应该是:
store: new Terraformer.GeoStore.Memory(),http://terraformer.io/geostore/

发布于 2019-11-23 06:46:37
如果您想在web worker中使用terraformer,则必须更改源代码以使其能够在web worker中工作。
在浏览器UI主线程中,不需要更改源代码。
我的意思是,如果在浏览器中,不需要修改源代码,你可以这样做:
<script src="https://unpkg.com/terraformer@1.0.7"></script>
<script src="https://unpkg.com/terraformer-geostore@1.0.4/browser/terraformer-geostore.js"></script>
// create a new GeoStore using Memory and an RTree Index
var store = new Terraformer.GeoStore({
//wrong, document: store: new Terraformer.Store.Memory(),
store: new Terraformer.GeoStore.Memory(),
index: new Terraformer.RTree()
});但如果在web worker中,您必须更改源代码:
// must use our customized version, 'window' is not available in web worker scope.
// 'window ' only available in UI main thread, so if(typeof window === "object"), must change to
// if(typeof WorkerGlobalScope === "function")
//importScripts('https://unpkg.com/terraformer@1.0.9') // original
importScripts('../../utility/terraformer/terraformer.js')
console.log('typeof WorkerGlobalScope - ', (typeof WorkerGlobalScope)) // function
console.log('typeof window - ', (typeof window)) // undefined
console.log('typeof navigator - ', (typeof navigator)) // object这是自定义代码,terraformer.js仅适用于web worker。

https://stackoverflow.com/questions/59001735
复制相似问题