calvinmetcalf / shapefile-js

Convert a Shapefile to GeoJSON. Not many caveats.
http://calvinmetcalf.github.io/shapefile-js/
715 stars 228 forks source link

when import mockjs you have todo this. #110

Closed skynice closed 2 years ago

skynice commented 5 years ago

hi,i use mockjs in my project.found the mockjs rewrite window.XMLHttpRequest. when ajax load .shp file the respnse type is string. then you todo like this,

import Mock from 'mockjs'
...
...
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
Mock.XHR.prototype.send = function() {
  if (this.custom.xhr) {
    this.custom.xhr.withCredentials = this.withCredentials || false
  }
  if(this.responseType==="arraybuffer"){
    //load .shp file
    this.custom.xhr.responseType="arraybuffer"
  }
  this.proxy_send(...arguments)
}
calvinmetcalf commented 5 years ago

is there a question ? I don't understand, this seems like a bug with mockjs maybe ?