Display shapefile map on web browser using angular2

IsharaD

I want to display shapefile map on the web browser using my angular2 application. Following is my code snippet and I use leaflet javascript library. But it fails in loading 'Geology.zip' file. Is there any specific way of loading zip files in angular applications? or any possible way of doing this?

var shpfile = new L.Shapefile('Geology.zip', {
    onEachFeature: function(feature, layer) {
        if (feature.properties) {
            layer.bindPopup(Object.keys(feature.properties).map(function(k) {
                return k + ": " + feature.properties[k];
            }).join("<br />"), {
                maxHeight: 200
            });
        }
    }
});
shpfile.addTo(m);
shpfile.once("data:loaded", function() {
    console.log("finished loaded shapefile");
});
kboul

According to this this library,that you are tryingto use, is deprecated and from what I have tried it is not possible to install it using npm.

Therefore you can use f.i this library to display a Shapefile using Leaflet after converting it to GeoJSON.

import 'leaflet';
import * as shp from 'shpjs';
declare let L;

ngOnInit() {
    const m = L.map('map').setView([34.74161249883172, 18.6328125], 2);
    const geo = L.geoJson({features: []}, { onEachFeature: function popUp(f, l) {
        const out = [];
        if (f.properties) {
            for (const key of Object.keys(f.properties)) {
                out.push(key + ' : ' + f.properties[key]);
            }
            l.bindPopup(out.join('<br />'));
        }
    }}).addTo(m);
    const base = 'your-shapefile.zip';
        shp(base).then(function(data) {
            geo.addData(data);
    });
}

However several errors arise and you can overcome them if you check this demo

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Silently open a web browser using Java code

分類Dev

Plot shapefile city borders on top of cartopy map

分類Dev

Angular2 this.route.params.map

分類Dev

Angular2 this.route.params.map

分類Dev

Frequent 2 minutes pauses on web browser requests

分類Dev

WPF application using CEFSharp Web Browser crashing in clickonce release

分類Dev

html element's attribute in c# web browser by using threading

分類Dev

Using ggplot to plot shapefile and gganimate for animation

分類Dev

Subsetting NYC shapefile to Manhattan using Geopandas

分類Dev

How to fetch a web page from a web site with URL using the web browser?

分類Dev

Close browser tab and exit Angular2 application

分類Dev

Display tabs using angular 5?

分類Dev

Angular2 Navigation using Arrow Keys

分類Dev

Using Angular2 With Material Design Lite

分類Dev

My favicon will not display on a browser tab for my app when using open source shiny server

分類Dev

How can I display a div if a user is using a browser not supported by Twitter Bootstrap

分類Dev

Angular2 +のWebトークン

分類Dev

Angular2 RC2 404 GET /browser-sync/browser-sync-client.2.12.5.js

分類Dev

How to close web browser window from code behind page after form post request completes, in razor web app using .netcore

分類Dev

Web application with Angular CLI does not display bootstrap-sass glyphicons

分類Dev

GeoJson is not working in Angular using Bing Map

分類Dev

How to correctly run Angular2 dart application in Dartium browser from IDEA?

分類Dev

Display html text using Struts2

分類Dev

Error when using trying to use angular2/Http

分類Dev

JQueryUI Sortable not working when using custom component with Angular2

分類Dev

Slow rendering of template using angular2 *ngFor

分類Dev

Change legend position of ng-charts (using angular2)

分類Dev

How to deploy Angular2 project without using CLI

分類Dev

General error handler for Angular2 application using Material Design

Related 関連記事

  1. 1

    Silently open a web browser using Java code

  2. 2

    Plot shapefile city borders on top of cartopy map

  3. 3

    Angular2 this.route.params.map

  4. 4

    Angular2 this.route.params.map

  5. 5

    Frequent 2 minutes pauses on web browser requests

  6. 6

    WPF application using CEFSharp Web Browser crashing in clickonce release

  7. 7

    html element's attribute in c# web browser by using threading

  8. 8

    Using ggplot to plot shapefile and gganimate for animation

  9. 9

    Subsetting NYC shapefile to Manhattan using Geopandas

  10. 10

    How to fetch a web page from a web site with URL using the web browser?

  11. 11

    Close browser tab and exit Angular2 application

  12. 12

    Display tabs using angular 5?

  13. 13

    Angular2 Navigation using Arrow Keys

  14. 14

    Using Angular2 With Material Design Lite

  15. 15

    My favicon will not display on a browser tab for my app when using open source shiny server

  16. 16

    How can I display a div if a user is using a browser not supported by Twitter Bootstrap

  17. 17

    Angular2 +のWebトークン

  18. 18

    Angular2 RC2 404 GET /browser-sync/browser-sync-client.2.12.5.js

  19. 19

    How to close web browser window from code behind page after form post request completes, in razor web app using .netcore

  20. 20

    Web application with Angular CLI does not display bootstrap-sass glyphicons

  21. 21

    GeoJson is not working in Angular using Bing Map

  22. 22

    How to correctly run Angular2 dart application in Dartium browser from IDEA?

  23. 23

    Display html text using Struts2

  24. 24

    Error when using trying to use angular2/Http

  25. 25

    JQueryUI Sortable not working when using custom component with Angular2

  26. 26

    Slow rendering of template using angular2 *ngFor

  27. 27

    Change legend position of ng-charts (using angular2)

  28. 28

    How to deploy Angular2 project without using CLI

  29. 29

    General error handler for Angular2 application using Material Design

ホットタグ

アーカイブ