How to write hyperlinks to local files in GeoJSON properties?Clickable hyperlink from GeoJSON field in featureHow to make a displayed geoJson property a link to another property in a Leaflet popupGeoJSON opening hyperlink to local file in the local aplication instead of browserSelect independent objects using GEOJson on OpenlayersSelecting feature programmatically from GeoJSON using OpenLayers?Loading GEOJSON in Leaflet and separating attributesMarkerCluster don't work with geojson layer in leafletChange style of GeoJSON circle marker by feature propertiesLeaflet L.geoJSON from a js variable geojson object not showing on mapHow to append geojson file using featureselectionGet GeoJSON from a database by the AJAX method for OpenLayers

Do beef farmed pastures net remove carbon emissions?

Is it legal for a company to enter an agreement not to hire employees from another company?

Are differences between uniformly distributed numbers uniformly distributed?

How much maintenance time did it take to make an F4U Corsair ready for another flight?

Is there any way to stop a user from creating executables and running them?

How do some PhD students get 10+ papers? Is that what I need for landing good faculty position?

Does the Fireball spell damage objects?

How to describe accents?

Annotating a table with arrows

Why does the standard fingering / strumming for a D maj chord leave out the 5th string?

Why are Tucker and Malcolm not dead?

Why did I get only 5 points even though I won?

What is a good class if we remove subclasses?

A Word/Phrase for the Process of Classifying Something as a Sin

Can a PC use the Levitate spell to avoid movement speed reduction from exhaustion?

Submitting a new paper just after another was accepted by the same journal

Generate Brainfuck for the numbers 1–255

Understanding the point of a kölsche Witz

What ability do tools use?

How would timezones work on a planet 100 times the size of our Earth

Can the ground attached to neutral fool a receptacle tester?

How far did Gandalf and the Balrog drop from the bridge in Moria?

Why did Gandalf use a sword against the Balrog?

How does "Te vas a cansar" mean "You're going to get tired"?



How to write hyperlinks to local files in GeoJSON properties?


Clickable hyperlink from GeoJSON field in featureHow to make a displayed geoJson property a link to another property in a Leaflet popupGeoJSON opening hyperlink to local file in the local aplication instead of browserSelect independent objects using GEOJson on OpenlayersSelecting feature programmatically from GeoJSON using OpenLayers?Loading GEOJSON in Leaflet and separating attributesMarkerCluster don't work with geojson layer in leafletChange style of GeoJSON circle marker by feature propertiesLeaflet L.geoJSON from a js variable geojson object not showing on mapHow to append geojson file using featureselectionGet GeoJSON from a database by the AJAX method for OpenLayers






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I am wondering how to make a hyperlink from GeoJSON file properties to the local drive file.
I found two options here:



Clickable hyperlink from GeoJSON field in feature
this option refers to a whole .geojson file, whereas I need to have an unique hyperlink for every single object property included in this file



This option:



How to make a displayed geoJson property a link to another property in a Leaflet popup



Looks better, but I have problems with implementation it into my code, that looks:



var church = L.geoJSON(test, 
pointToLayer: function(feature, latlng)
feature.properties.myKey =
feature.properties.Title + ", " + feature.properties.Head;
return L.circleMarker(latlng, geojsonMarkerOptions2);
,
onEachFeature: function(feature, layer)
layer.bindPopup(
'<h1><u><font color="red">' +
feature.properties.Title +
"</h1></u></font><h2>Address: " +
feature.properties.Head +
"</h2><p>" +
feature.properties.Description +
"</p><a href='" +
feature.properties.URL +
"'>"
);

).addTo(map);


Once I put a single link in GeoJSON file property, then works fine:




"type": "FeatureCollection",
"features": [

"type": "Feature",
"properties":
"Title": "Sitec IS",
"Head": "7400 Beach Drive",
"Description": "Gavin Sinclair"
,
"geometry":
"type": "Point",
"coordinates": [0.16964435577392578, 52.29220753602784]

,

"type": "Feature",
"properties":
"Title": "JHG",
"Head": "Shortstanton sidings",
"Description": "Conor Murphy",
"URL": "<a href='https://www.johnhenrygroup.co.uk/' target='blank'>JHG</a>"
,
"geometry":
"type": "Point",
"coordinates": [0.05458831787109375, 52.29163006501503]


]



However I would like to have a path to my local file instead of URL...




"type": "FeatureCollection",
"features": [

"type": "Feature",
"properties":
"Title": "Priory Court",
"Head": "188 Albany Road",
"Description": "MDU",
"URL": "file:\Z:Fixed LineDesign & Build2. ClientsOpenreach3. MDU DesignsCoventryOR66 - Priory Court, Coventry"
,
"geometry":
"type": "Point",
"coordinates": [-1.530101, 52.400199]

,

"type": "Feature",
"properties":
"Title": "Stretham house",
"Head": "Flat to leave",
"Description": "N/A"
,
"geometry":
"type": "Point",
"coordinates": [0.211212, 52.344149]


]



but the code doesn't work at all.
I believe, that problem lies somewhere in the apostrophs/quotation marks. I have an empty text instead or nothing.



Is there some option to make the hyperlink towards a specified path in the local drive file/folder, analogically i.e to the MS Excel?



Hyperlink to the local file










share|improve this question
































    2















    I am wondering how to make a hyperlink from GeoJSON file properties to the local drive file.
    I found two options here:



    Clickable hyperlink from GeoJSON field in feature
    this option refers to a whole .geojson file, whereas I need to have an unique hyperlink for every single object property included in this file



    This option:



    How to make a displayed geoJson property a link to another property in a Leaflet popup



    Looks better, but I have problems with implementation it into my code, that looks:



    var church = L.geoJSON(test, 
    pointToLayer: function(feature, latlng)
    feature.properties.myKey =
    feature.properties.Title + ", " + feature.properties.Head;
    return L.circleMarker(latlng, geojsonMarkerOptions2);
    ,
    onEachFeature: function(feature, layer)
    layer.bindPopup(
    '<h1><u><font color="red">' +
    feature.properties.Title +
    "</h1></u></font><h2>Address: " +
    feature.properties.Head +
    "</h2><p>" +
    feature.properties.Description +
    "</p><a href='" +
    feature.properties.URL +
    "'>"
    );

    ).addTo(map);


    Once I put a single link in GeoJSON file property, then works fine:




    "type": "FeatureCollection",
    "features": [

    "type": "Feature",
    "properties":
    "Title": "Sitec IS",
    "Head": "7400 Beach Drive",
    "Description": "Gavin Sinclair"
    ,
    "geometry":
    "type": "Point",
    "coordinates": [0.16964435577392578, 52.29220753602784]

    ,

    "type": "Feature",
    "properties":
    "Title": "JHG",
    "Head": "Shortstanton sidings",
    "Description": "Conor Murphy",
    "URL": "<a href='https://www.johnhenrygroup.co.uk/' target='blank'>JHG</a>"
    ,
    "geometry":
    "type": "Point",
    "coordinates": [0.05458831787109375, 52.29163006501503]


    ]



    However I would like to have a path to my local file instead of URL...




    "type": "FeatureCollection",
    "features": [

    "type": "Feature",
    "properties":
    "Title": "Priory Court",
    "Head": "188 Albany Road",
    "Description": "MDU",
    "URL": "file:\Z:Fixed LineDesign & Build2. ClientsOpenreach3. MDU DesignsCoventryOR66 - Priory Court, Coventry"
    ,
    "geometry":
    "type": "Point",
    "coordinates": [-1.530101, 52.400199]

    ,

    "type": "Feature",
    "properties":
    "Title": "Stretham house",
    "Head": "Flat to leave",
    "Description": "N/A"
    ,
    "geometry":
    "type": "Point",
    "coordinates": [0.211212, 52.344149]


    ]



    but the code doesn't work at all.
    I believe, that problem lies somewhere in the apostrophs/quotation marks. I have an empty text instead or nothing.



    Is there some option to make the hyperlink towards a specified path in the local drive file/folder, analogically i.e to the MS Excel?



    Hyperlink to the local file










    share|improve this question




























      2












      2








      2








      I am wondering how to make a hyperlink from GeoJSON file properties to the local drive file.
      I found two options here:



      Clickable hyperlink from GeoJSON field in feature
      this option refers to a whole .geojson file, whereas I need to have an unique hyperlink for every single object property included in this file



      This option:



      How to make a displayed geoJson property a link to another property in a Leaflet popup



      Looks better, but I have problems with implementation it into my code, that looks:



      var church = L.geoJSON(test, 
      pointToLayer: function(feature, latlng)
      feature.properties.myKey =
      feature.properties.Title + ", " + feature.properties.Head;
      return L.circleMarker(latlng, geojsonMarkerOptions2);
      ,
      onEachFeature: function(feature, layer)
      layer.bindPopup(
      '<h1><u><font color="red">' +
      feature.properties.Title +
      "</h1></u></font><h2>Address: " +
      feature.properties.Head +
      "</h2><p>" +
      feature.properties.Description +
      "</p><a href='" +
      feature.properties.URL +
      "'>"
      );

      ).addTo(map);


      Once I put a single link in GeoJSON file property, then works fine:




      "type": "FeatureCollection",
      "features": [

      "type": "Feature",
      "properties":
      "Title": "Sitec IS",
      "Head": "7400 Beach Drive",
      "Description": "Gavin Sinclair"
      ,
      "geometry":
      "type": "Point",
      "coordinates": [0.16964435577392578, 52.29220753602784]

      ,

      "type": "Feature",
      "properties":
      "Title": "JHG",
      "Head": "Shortstanton sidings",
      "Description": "Conor Murphy",
      "URL": "<a href='https://www.johnhenrygroup.co.uk/' target='blank'>JHG</a>"
      ,
      "geometry":
      "type": "Point",
      "coordinates": [0.05458831787109375, 52.29163006501503]


      ]



      However I would like to have a path to my local file instead of URL...




      "type": "FeatureCollection",
      "features": [

      "type": "Feature",
      "properties":
      "Title": "Priory Court",
      "Head": "188 Albany Road",
      "Description": "MDU",
      "URL": "file:\Z:Fixed LineDesign & Build2. ClientsOpenreach3. MDU DesignsCoventryOR66 - Priory Court, Coventry"
      ,
      "geometry":
      "type": "Point",
      "coordinates": [-1.530101, 52.400199]

      ,

      "type": "Feature",
      "properties":
      "Title": "Stretham house",
      "Head": "Flat to leave",
      "Description": "N/A"
      ,
      "geometry":
      "type": "Point",
      "coordinates": [0.211212, 52.344149]


      ]



      but the code doesn't work at all.
      I believe, that problem lies somewhere in the apostrophs/quotation marks. I have an empty text instead or nothing.



      Is there some option to make the hyperlink towards a specified path in the local drive file/folder, analogically i.e to the MS Excel?



      Hyperlink to the local file










      share|improve this question
















      I am wondering how to make a hyperlink from GeoJSON file properties to the local drive file.
      I found two options here:



      Clickable hyperlink from GeoJSON field in feature
      this option refers to a whole .geojson file, whereas I need to have an unique hyperlink for every single object property included in this file



      This option:



      How to make a displayed geoJson property a link to another property in a Leaflet popup



      Looks better, but I have problems with implementation it into my code, that looks:



      var church = L.geoJSON(test, 
      pointToLayer: function(feature, latlng)
      feature.properties.myKey =
      feature.properties.Title + ", " + feature.properties.Head;
      return L.circleMarker(latlng, geojsonMarkerOptions2);
      ,
      onEachFeature: function(feature, layer)
      layer.bindPopup(
      '<h1><u><font color="red">' +
      feature.properties.Title +
      "</h1></u></font><h2>Address: " +
      feature.properties.Head +
      "</h2><p>" +
      feature.properties.Description +
      "</p><a href='" +
      feature.properties.URL +
      "'>"
      );

      ).addTo(map);


      Once I put a single link in GeoJSON file property, then works fine:




      "type": "FeatureCollection",
      "features": [

      "type": "Feature",
      "properties":
      "Title": "Sitec IS",
      "Head": "7400 Beach Drive",
      "Description": "Gavin Sinclair"
      ,
      "geometry":
      "type": "Point",
      "coordinates": [0.16964435577392578, 52.29220753602784]

      ,

      "type": "Feature",
      "properties":
      "Title": "JHG",
      "Head": "Shortstanton sidings",
      "Description": "Conor Murphy",
      "URL": "<a href='https://www.johnhenrygroup.co.uk/' target='blank'>JHG</a>"
      ,
      "geometry":
      "type": "Point",
      "coordinates": [0.05458831787109375, 52.29163006501503]


      ]



      However I would like to have a path to my local file instead of URL...




      "type": "FeatureCollection",
      "features": [

      "type": "Feature",
      "properties":
      "Title": "Priory Court",
      "Head": "188 Albany Road",
      "Description": "MDU",
      "URL": "file:\Z:Fixed LineDesign & Build2. ClientsOpenreach3. MDU DesignsCoventryOR66 - Priory Court, Coventry"
      ,
      "geometry":
      "type": "Point",
      "coordinates": [-1.530101, 52.400199]

      ,

      "type": "Feature",
      "properties":
      "Title": "Stretham house",
      "Head": "Flat to leave",
      "Description": "N/A"
      ,
      "geometry":
      "type": "Point",
      "coordinates": [0.211212, 52.344149]


      ]



      but the code doesn't work at all.
      I believe, that problem lies somewhere in the apostrophs/quotation marks. I have an empty text instead or nothing.



      Is there some option to make the hyperlink towards a specified path in the local drive file/folder, analogically i.e to the MS Excel?



      Hyperlink to the local file







      leaflet javascript geojson hyperlink






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 8 hours ago









      IvanSanchez

      6,9221 gold badge10 silver badges22 bronze badges




      6,9221 gold badge10 silver badges22 bronze badges










      asked 9 hours ago









      Mariusz KrukarMariusz Krukar

      287 bronze badges




      287 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          4














          Couple of subtly wrong things here.



          1. A file URL starts with file:///, not with file:\, as per the WhatWG URL specification


          2. Backslashes in JSON must be escaped (from to \), as explained in this answer on stackoverflow


          Therefore, you should replace...



           "properties": 
          "URL": "file:\Z:Fixed LineDesign ..."
          ,


          ...with something like...



           "properties": 
          "URL": "file:///Z:\Fixed Line\Design ..."
          ,


          Note that, because it's a escaped string, doing a console.log(feature.properties.URL) will output file:///Z:Fixed LineDesign....



          Also note that, because of how you're concatenating strings together at...



          layer.bindPopup("<a href='" + feature.properties.URL + "'>");


          ...things will fail if your filenames contain quotes or double quotes. Consider using encodeURI() (don't forget to check the reference), e.g.:



          layer.bindPopup("<a href='" + encodeURI(feature.properties.URL) + "'>");





          share|improve this answer



























            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
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f331746%2fhow-to-write-hyperlinks-to-local-files-in-geojson-properties%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            Couple of subtly wrong things here.



            1. A file URL starts with file:///, not with file:\, as per the WhatWG URL specification


            2. Backslashes in JSON must be escaped (from to \), as explained in this answer on stackoverflow


            Therefore, you should replace...



             "properties": 
            "URL": "file:\Z:Fixed LineDesign ..."
            ,


            ...with something like...



             "properties": 
            "URL": "file:///Z:\Fixed Line\Design ..."
            ,


            Note that, because it's a escaped string, doing a console.log(feature.properties.URL) will output file:///Z:Fixed LineDesign....



            Also note that, because of how you're concatenating strings together at...



            layer.bindPopup("<a href='" + feature.properties.URL + "'>");


            ...things will fail if your filenames contain quotes or double quotes. Consider using encodeURI() (don't forget to check the reference), e.g.:



            layer.bindPopup("<a href='" + encodeURI(feature.properties.URL) + "'>");





            share|improve this answer





























              4














              Couple of subtly wrong things here.



              1. A file URL starts with file:///, not with file:\, as per the WhatWG URL specification


              2. Backslashes in JSON must be escaped (from to \), as explained in this answer on stackoverflow


              Therefore, you should replace...



               "properties": 
              "URL": "file:\Z:Fixed LineDesign ..."
              ,


              ...with something like...



               "properties": 
              "URL": "file:///Z:\Fixed Line\Design ..."
              ,


              Note that, because it's a escaped string, doing a console.log(feature.properties.URL) will output file:///Z:Fixed LineDesign....



              Also note that, because of how you're concatenating strings together at...



              layer.bindPopup("<a href='" + feature.properties.URL + "'>");


              ...things will fail if your filenames contain quotes or double quotes. Consider using encodeURI() (don't forget to check the reference), e.g.:



              layer.bindPopup("<a href='" + encodeURI(feature.properties.URL) + "'>");





              share|improve this answer



























                4












                4








                4







                Couple of subtly wrong things here.



                1. A file URL starts with file:///, not with file:\, as per the WhatWG URL specification


                2. Backslashes in JSON must be escaped (from to \), as explained in this answer on stackoverflow


                Therefore, you should replace...



                 "properties": 
                "URL": "file:\Z:Fixed LineDesign ..."
                ,


                ...with something like...



                 "properties": 
                "URL": "file:///Z:\Fixed Line\Design ..."
                ,


                Note that, because it's a escaped string, doing a console.log(feature.properties.URL) will output file:///Z:Fixed LineDesign....



                Also note that, because of how you're concatenating strings together at...



                layer.bindPopup("<a href='" + feature.properties.URL + "'>");


                ...things will fail if your filenames contain quotes or double quotes. Consider using encodeURI() (don't forget to check the reference), e.g.:



                layer.bindPopup("<a href='" + encodeURI(feature.properties.URL) + "'>");





                share|improve this answer













                Couple of subtly wrong things here.



                1. A file URL starts with file:///, not with file:\, as per the WhatWG URL specification


                2. Backslashes in JSON must be escaped (from to \), as explained in this answer on stackoverflow


                Therefore, you should replace...



                 "properties": 
                "URL": "file:\Z:Fixed LineDesign ..."
                ,


                ...with something like...



                 "properties": 
                "URL": "file:///Z:\Fixed Line\Design ..."
                ,


                Note that, because it's a escaped string, doing a console.log(feature.properties.URL) will output file:///Z:Fixed LineDesign....



                Also note that, because of how you're concatenating strings together at...



                layer.bindPopup("<a href='" + feature.properties.URL + "'>");


                ...things will fail if your filenames contain quotes or double quotes. Consider using encodeURI() (don't forget to check the reference), e.g.:



                layer.bindPopup("<a href='" + encodeURI(feature.properties.URL) + "'>");






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 8 hours ago









                IvanSanchezIvanSanchez

                6,9221 gold badge10 silver badges22 bronze badges




                6,9221 gold badge10 silver badges22 bronze badges






























                    draft saved

                    draft discarded
















































                    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%2f331746%2fhow-to-write-hyperlinks-to-local-files-in-geojson-properties%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

                    Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                    Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                    François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480