Get 3D data from google earth.
This project is a combination of the amazing work from retroplasma/earth-reverse-engineering and LexSong/earth-reverse-engineering-utils put together to form a usable library.
yarn add https://github.com/AIFanatic/earth-3d
<script src="https://cdn.jsdelivr.net/gh/AIFAnatic/earth-3d@latest/dist/earth-3d-bundle.js"></script>
import { NodeManager } from 'https://cdn.jsdelivr.net/gh/AIFAnatic/earth-3d@latest/dist/earth-3d-esm-bundle.js';
import { NodeManager, LatLonBox } from 'earth-3d';
const filterLatLonBox = new LatLonBox(37.304420471191406, 37.3040771484375, -121.88644409179688, -121.88610076904297);
const nodeValidationHandler = (node) => {
// Filter nodes based on some criteria
return LatLonBox.is_overlapping(filterLatLonBox, node.latLonBox);
}
const nodeManager = new NodeManager({
nodeValidationHandler: nodeValidationHandler
});
setInterval(() => {
const nodes = nodeManager.get_nodes();
}, 100);
Notes:
- Since nodes are stored in an octree fashion you cannot just filter the "end" node, all the nodes that belong to the same path at a previous level also need to be included.
- Filtering should be performed with caution, having a big LatLonBox will likely result in a temporary ban from google since it will try and pull all the nodes at all levels.
- The
nodeValidationHandler
method passes aNodeHeader
which contains the node LatLonBox and OBB, they can be used to filter nodes based on any criteria. - When using this library the file
ResourcesWorker.js
needs to be copied manually into your distribution directory. - Nodes need to be filtered and fetched asynchronously, therefore, multiple calls to
getNodes
is expected in order to retrieve all the nodes for a query.
- Documentation
This project has no affiliation with Google or any of its affiliates, there may by a chance that you will get a temporary ban from using google maps services due to the high volume of tiles being streamed.