123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- import { createHashMap } from 'zrender/lib/core/util.js';
- import { GeoSVGResource } from './GeoSVGResource.js';
- import { GeoJSONResource } from './GeoJSONResource.js';
- var storage = createHashMap();
- export default {
-
- registerMap: function (mapName, rawDef, rawSpecialAreas) {
- if (rawDef.svg) {
- var resource = new GeoSVGResource(mapName, rawDef.svg);
- storage.set(mapName, resource);
- } else {
-
-
-
-
-
- var geoJSON = rawDef.geoJson || rawDef.geoJSON;
- if (geoJSON && !rawDef.features) {
- rawSpecialAreas = rawDef.specialAreas;
- } else {
- geoJSON = rawDef;
- }
- var resource = new GeoJSONResource(mapName, geoJSON, rawSpecialAreas);
- storage.set(mapName, resource);
- }
- },
- getGeoResource: function (mapName) {
- return storage.get(mapName);
- },
-
- getMapForUser: function (mapName) {
- var resource = storage.get(mapName);
- return resource && resource.type === 'geoJSON' && resource.getMapForUser();
- },
- load: function (mapName, nameMap, nameProperty) {
- var resource = storage.get(mapName);
- if (!resource) {
- if (process.env.NODE_ENV !== 'production') {
- console.error('Map ' + mapName + ' not exists. The GeoJSON of the map must be provided.');
- }
- return;
- }
- return resource.load(nameMap, nameProperty);
- }
- };
|