Leaflet: get layer in geojson with pixelcoordinates instead of latlng coordinatesReprojecting coordinates and...

Dot product with a constant

What is formjacking?

In the Lost in Space intro why was Dr. Smith actor listed as a special guest star?

What does "don't have a baby" imply or mean in this sentence?

Draw triangle with text in vertices/edges

Why don't you get burned by the wood benches in a sauna?

Add number in the string after each letter

How can I persuade an unwilling soul to become willing?

Checking if an integer permutation is cyclic in Java

Why does this quiz question say that protons and electrons do not combine to form neutrons?

How do I avoid the "chosen hero" feeling?

Have any astronauts or cosmonauts died in space?

I am a loser when it comes to jobs, what possibilities do I have?

Can a planet be tidally unlocked?

Why and/or operations in python statement are behaving unexpectedly?

How to store all ctor parameters in fields

What legally stops the UK from having another referendum on Brexit

Can someone explain the need for perturbation theory in QM?

Integral problem. Unsure of the approach.

Coworker is trying to get me to sign his petition to run for office. How to decline politely?

Do the speed limit reductions due to pollution also apply to electric cars in France?

Including proofs of known theorems in master's thesis

Why don't programs completely uninstall (remove all their files) when I remove them?

What's the meaning of #0?



Leaflet: get layer in geojson with pixelcoordinates instead of latlng coordinates


Reprojecting coordinates and geoJSON in leafletOpenLayers3 vs Leaflet for styling multifeature geojsonUsing Mapbox (LeafletJS), how do I edit imported shapes from GeoJSON?Zoom to GeoJSON point feature in leafletVector under OSMbuildingsLeaflet: Capturing points for features inside circleLeaflet GeoJSON with projected coordinates (3857)leaflet: current location in geojson polygonsHow to get leaflet polyline segment length?Save Leaflet drawn features with attributes to PostGIS













0















In my Angular 7 project with ngx-leaflet and leaflet 1.4.0 and leaflet-draw 0.4.14 I want to export each drawn rectangle (and circle,...) to geojson.
That works fine using



 public onDrawCreated(e: any) {
const layerType = e.layerType;
const layer = e.layer;
const gj = layer.toGeoJSON();
// .... save gj
}


Now I also want to have the geoJSON with pixel coordinates instead of the latlng coordinates as they come from the layer.
So I suppose I need to execute a project on all coordinates using



this.map.project(ltlng, this.map.getMaxZoom()).round();


However: this.map.project returns a point object not a latlng object.
I tried to apply this conversion on the _latlngs property of the layer object, but obviously it does not work.
Should I do the conversion on the geoJSON object?
Any tips on how I can make this conversion work?









share







New contributor




Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    In my Angular 7 project with ngx-leaflet and leaflet 1.4.0 and leaflet-draw 0.4.14 I want to export each drawn rectangle (and circle,...) to geojson.
    That works fine using



     public onDrawCreated(e: any) {
    const layerType = e.layerType;
    const layer = e.layer;
    const gj = layer.toGeoJSON();
    // .... save gj
    }


    Now I also want to have the geoJSON with pixel coordinates instead of the latlng coordinates as they come from the layer.
    So I suppose I need to execute a project on all coordinates using



    this.map.project(ltlng, this.map.getMaxZoom()).round();


    However: this.map.project returns a point object not a latlng object.
    I tried to apply this conversion on the _latlngs property of the layer object, but obviously it does not work.
    Should I do the conversion on the geoJSON object?
    Any tips on how I can make this conversion work?









    share







    New contributor




    Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      In my Angular 7 project with ngx-leaflet and leaflet 1.4.0 and leaflet-draw 0.4.14 I want to export each drawn rectangle (and circle,...) to geojson.
      That works fine using



       public onDrawCreated(e: any) {
      const layerType = e.layerType;
      const layer = e.layer;
      const gj = layer.toGeoJSON();
      // .... save gj
      }


      Now I also want to have the geoJSON with pixel coordinates instead of the latlng coordinates as they come from the layer.
      So I suppose I need to execute a project on all coordinates using



      this.map.project(ltlng, this.map.getMaxZoom()).round();


      However: this.map.project returns a point object not a latlng object.
      I tried to apply this conversion on the _latlngs property of the layer object, but obviously it does not work.
      Should I do the conversion on the geoJSON object?
      Any tips on how I can make this conversion work?









      share







      New contributor




      Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      In my Angular 7 project with ngx-leaflet and leaflet 1.4.0 and leaflet-draw 0.4.14 I want to export each drawn rectangle (and circle,...) to geojson.
      That works fine using



       public onDrawCreated(e: any) {
      const layerType = e.layerType;
      const layer = e.layer;
      const gj = layer.toGeoJSON();
      // .... save gj
      }


      Now I also want to have the geoJSON with pixel coordinates instead of the latlng coordinates as they come from the layer.
      So I suppose I need to execute a project on all coordinates using



      this.map.project(ltlng, this.map.getMaxZoom()).round();


      However: this.map.project returns a point object not a latlng object.
      I tried to apply this conversion on the _latlngs property of the layer object, but obviously it does not work.
      Should I do the conversion on the geoJSON object?
      Any tips on how I can make this conversion work?







      leaflet leaflet-draw





      share







      New contributor




      Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 4 mins ago









      BenBen

      1




      1




      New contributor




      Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Ben is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f313210%2fleaflet-get-layer-in-geojson-with-pixelcoordinates-instead-of-latlng-coordinate%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Ben is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Ben is a new contributor. Be nice, and check out our Code of Conduct.













          Ben is a new contributor. Be nice, and check out our Code of Conduct.












          Ben is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f313210%2fleaflet-get-layer-in-geojson-with-pixelcoordinates-instead-of-latlng-coordinate%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

          Meter-Bus Содержание Параметры шины | Стандартизация |...