diff --git a/README.md b/README.md index 928131c..e1942e5 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ import { Map } from 'react-leaflet'; import ReactLeafletKml from 'react-leaflet-kml'; const kmlText='YOUR KML FILE AS TEXT'; +const parser = new DOMParser(); +const kml = parser.parseFromString(kmlText, 'text/xml'); export class App extends React.Component { render() { @@ -22,7 +24,7 @@ export class App extends React.Component { - + ); } diff --git a/package.json b/package.json index 17bdd83..b5fe494 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-leaflet-kml", - "version": "1.0.2", + "version": "1.0.3", "description": "React leaflet wrapper of leaflet-kml", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/__tests__/ReactLeafletKml.test.tsx b/src/__tests__/ReactLeafletKml.test.tsx index 238d9ac..19e8ea2 100644 --- a/src/__tests__/ReactLeafletKml.test.tsx +++ b/src/__tests__/ReactLeafletKml.test.tsx @@ -8,7 +8,7 @@ test('ReactLeafletKml', () => { const component = ReactTestUtils.renderIntoDocument( - + ) as any; expect(component.leafletElement._container).toBeDefined() diff --git a/src/index.ts b/src/index.ts index 0ca7054..7436e19 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,13 +5,13 @@ import { ContextProps, MapLayer, withLeaflet } from 'react-leaflet'; import 'leaflet-kml'; interface IProps extends ContextProps { - kml: string; + kml: XMLDocument; } class ReactLeafletKml extends MapLayer { public createLeafletElement(props: IProps) { const { kml } = props; - this.leafletElement = new L.KML(new DOMParser().parseFromString(kml, "text/xml")); + this.leafletElement = new L.KML(kml); if (this.props.leaflet.map.options.preferCanvas) { setTimeout((map: LeafletContext.map) => { // Handling react-leaflet bug of canvas renderer not updating