How do I override default popup anchor in Leaflet GeoJSON polygon? Planned maintenance...

Continue tikz picture on next page

How to charge percentage of transaction cost?

What's the connection between Mr. Nancy and fried chicken?

Can a Wizard take the Magic Initiate feat and select spells from the Wizard list?

Is "ein Herz wie das meine" an antiquated or colloquial use of the possesive pronoun?

Is the Mordenkainen's Sword spell underpowered?

How to leave only the following strings?

Why does my GNOME settings mention "Moto C Plus"?

Where is Bhagavad Gita referred to as Hari Gita?

Why do people think Winterfell crypts is the safest place for women, children & old people?

Pointing to problems without suggesting solutions

Like totally amazing interchangeable sister outfit accessory swapping or whatever

Can I take recommendation from someone I met at a conference?

What's the difference between using dependency injection with a container and using a service locator?

How do I deal with an erroneously large refund?

A German immigrant ancestor has a "Registration Affidavit of Alien Enemy" on file. What does that mean exactly?

Are Flameskulls resistant to magical piercing damage?

Does using the Inspiration rules for character defects encourage My Guy Syndrome?

Does GDPR cover the collection of data by websites that crawl the web and resell user data

lm and glm function in R

Do chord progressions usually move by fifths?

Short story about an alien named Ushtu(?) coming from a future Earth, when ours was destroyed by a nuclear explosion

Has a Nobel Peace laureate ever been accused of war crimes?

Who can become a wight?



How do I override default popup anchor in Leaflet GeoJSON polygon?



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Problems with features, popups and strategy with OpenLayersLeaflet Marker Mouseover PopupHow to add hyperlink in geojson popup in Leaflet?Leaflet popup options with geoJSON dataMarkerCluster don't work with geojson layer in leafletDisplaying properties of GeoJSON in popup on Leaflet?How to make a displayed geoJson property a link to another property in a Leaflet popupLeaflet - Popup description anchor on top of MarkerChanging anchor point for popup without marker using Leaflet?Leaflet: Different custom information popups for each GeoJSON polygon





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







1















By default popups open wherever you click within the boundaries of polygons in Leaflet geojson layers. Here's an example:



JsFiddle



I would like to anchor the popup either:



so it opens in a specific place on the map (setLatLong)



or



at a specific coordinate relative to where the cursor clicks on the polygon. (anchorPopup)



I know from docs that this can be achieved using anchorPopup or openPopup: if this be the case where does one add this to the code?



My code is similar to the jsfiddle:



var outcroppings = L.geoJson(outcroppings,{

style: function(feature, layer){
return {
color: "black",
fillColor: "orange",
fillOpacity: 6,
weight: 2,

};
},

onEachFeature: function (feature, layer){
layer.bindPopup(

"<img src='" + feature.properties.image + "'style= width:100px >"+
"</p>area: "+feature.properties.Shape_Area
);
}

}).addTo(map);









share|improve this question
















bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















    1















    By default popups open wherever you click within the boundaries of polygons in Leaflet geojson layers. Here's an example:



    JsFiddle



    I would like to anchor the popup either:



    so it opens in a specific place on the map (setLatLong)



    or



    at a specific coordinate relative to where the cursor clicks on the polygon. (anchorPopup)



    I know from docs that this can be achieved using anchorPopup or openPopup: if this be the case where does one add this to the code?



    My code is similar to the jsfiddle:



    var outcroppings = L.geoJson(outcroppings,{

    style: function(feature, layer){
    return {
    color: "black",
    fillColor: "orange",
    fillOpacity: 6,
    weight: 2,

    };
    },

    onEachFeature: function (feature, layer){
    layer.bindPopup(

    "<img src='" + feature.properties.image + "'style= width:100px >"+
    "</p>area: "+feature.properties.Shape_Area
    );
    }

    }).addTo(map);









    share|improve this question
















    bumped to the homepage by Community 5 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1








      By default popups open wherever you click within the boundaries of polygons in Leaflet geojson layers. Here's an example:



      JsFiddle



      I would like to anchor the popup either:



      so it opens in a specific place on the map (setLatLong)



      or



      at a specific coordinate relative to where the cursor clicks on the polygon. (anchorPopup)



      I know from docs that this can be achieved using anchorPopup or openPopup: if this be the case where does one add this to the code?



      My code is similar to the jsfiddle:



      var outcroppings = L.geoJson(outcroppings,{

      style: function(feature, layer){
      return {
      color: "black",
      fillColor: "orange",
      fillOpacity: 6,
      weight: 2,

      };
      },

      onEachFeature: function (feature, layer){
      layer.bindPopup(

      "<img src='" + feature.properties.image + "'style= width:100px >"+
      "</p>area: "+feature.properties.Shape_Area
      );
      }

      }).addTo(map);









      share|improve this question
















      By default popups open wherever you click within the boundaries of polygons in Leaflet geojson layers. Here's an example:



      JsFiddle



      I would like to anchor the popup either:



      so it opens in a specific place on the map (setLatLong)



      or



      at a specific coordinate relative to where the cursor clicks on the polygon. (anchorPopup)



      I know from docs that this can be achieved using anchorPopup or openPopup: if this be the case where does one add this to the code?



      My code is similar to the jsfiddle:



      var outcroppings = L.geoJson(outcroppings,{

      style: function(feature, layer){
      return {
      color: "black",
      fillColor: "orange",
      fillOpacity: 6,
      weight: 2,

      };
      },

      onEachFeature: function (feature, layer){
      layer.bindPopup(

      "<img src='" + feature.properties.image + "'style= width:100px >"+
      "</p>area: "+feature.properties.Shape_Area
      );
      }

      }).addTo(map);






      leaflet geojson popup






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 3 '18 at 20:36







      Eddie Arni

















      asked Jul 2 '18 at 21:24









      Eddie ArniEddie Arni

      60111




      60111





      bumped to the homepage by Community 5 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 5 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          You could try the setLatLng() method chained onto the popup. If you enter the coordinates where you want the popup to appear, it should stay in that location.



          So, I think it should look like this:



          onEachFeature: function (feature, layer){
          layer.bindPopup(

          "<img src='" + feature.properties.image + "'style=
          width:100px >"+
          "</p>area: "+feature.properties.Shape_Area
          );
          }

          }).setLatLng(LatLng).addTo(map);





          share|improve this answer
























          • Nope, that made the feature vanish.. :(

            – Eddie Arni
            Jul 3 '18 at 17:03











          • Do you get a message in the console, or does it just disappear?

            – Josh Beauchamp
            Jul 6 '18 at 17:23











          • I get a mesasage: TypeError: L.geoJson(...).setLatLng is not a function.

            – Eddie Arni
            Jul 7 '18 at 0:11











          • When I follow the error message it highlights ' var outcroppings= L.geojson(outcroppings, '

            – Eddie Arni
            Jul 7 '18 at 0:29











          • You cannot call setLatLng() on the layer, but this is what you are trying to do.

            – Stefan
            Sep 9 '18 at 10:13



















          0














          You need to initiate the popup with a layer source (see the Creation section of the popup documentation) and then set its coordinates:



          L.popup(popupOptions,layer).setContent(content).setLatLng(lat_lng)





          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%2f288229%2fhow-do-i-override-default-popup-anchor-in-leaflet-geojson-polygon%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You could try the setLatLng() method chained onto the popup. If you enter the coordinates where you want the popup to appear, it should stay in that location.



            So, I think it should look like this:



            onEachFeature: function (feature, layer){
            layer.bindPopup(

            "<img src='" + feature.properties.image + "'style=
            width:100px >"+
            "</p>area: "+feature.properties.Shape_Area
            );
            }

            }).setLatLng(LatLng).addTo(map);





            share|improve this answer
























            • Nope, that made the feature vanish.. :(

              – Eddie Arni
              Jul 3 '18 at 17:03











            • Do you get a message in the console, or does it just disappear?

              – Josh Beauchamp
              Jul 6 '18 at 17:23











            • I get a mesasage: TypeError: L.geoJson(...).setLatLng is not a function.

              – Eddie Arni
              Jul 7 '18 at 0:11











            • When I follow the error message it highlights ' var outcroppings= L.geojson(outcroppings, '

              – Eddie Arni
              Jul 7 '18 at 0:29











            • You cannot call setLatLng() on the layer, but this is what you are trying to do.

              – Stefan
              Sep 9 '18 at 10:13
















            0














            You could try the setLatLng() method chained onto the popup. If you enter the coordinates where you want the popup to appear, it should stay in that location.



            So, I think it should look like this:



            onEachFeature: function (feature, layer){
            layer.bindPopup(

            "<img src='" + feature.properties.image + "'style=
            width:100px >"+
            "</p>area: "+feature.properties.Shape_Area
            );
            }

            }).setLatLng(LatLng).addTo(map);





            share|improve this answer
























            • Nope, that made the feature vanish.. :(

              – Eddie Arni
              Jul 3 '18 at 17:03











            • Do you get a message in the console, or does it just disappear?

              – Josh Beauchamp
              Jul 6 '18 at 17:23











            • I get a mesasage: TypeError: L.geoJson(...).setLatLng is not a function.

              – Eddie Arni
              Jul 7 '18 at 0:11











            • When I follow the error message it highlights ' var outcroppings= L.geojson(outcroppings, '

              – Eddie Arni
              Jul 7 '18 at 0:29











            • You cannot call setLatLng() on the layer, but this is what you are trying to do.

              – Stefan
              Sep 9 '18 at 10:13














            0












            0








            0







            You could try the setLatLng() method chained onto the popup. If you enter the coordinates where you want the popup to appear, it should stay in that location.



            So, I think it should look like this:



            onEachFeature: function (feature, layer){
            layer.bindPopup(

            "<img src='" + feature.properties.image + "'style=
            width:100px >"+
            "</p>area: "+feature.properties.Shape_Area
            );
            }

            }).setLatLng(LatLng).addTo(map);





            share|improve this answer













            You could try the setLatLng() method chained onto the popup. If you enter the coordinates where you want the popup to appear, it should stay in that location.



            So, I think it should look like this:



            onEachFeature: function (feature, layer){
            layer.bindPopup(

            "<img src='" + feature.properties.image + "'style=
            width:100px >"+
            "</p>area: "+feature.properties.Shape_Area
            );
            }

            }).setLatLng(LatLng).addTo(map);






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 3 '18 at 4:05









            Josh BeauchampJosh Beauchamp

            565




            565













            • Nope, that made the feature vanish.. :(

              – Eddie Arni
              Jul 3 '18 at 17:03











            • Do you get a message in the console, or does it just disappear?

              – Josh Beauchamp
              Jul 6 '18 at 17:23











            • I get a mesasage: TypeError: L.geoJson(...).setLatLng is not a function.

              – Eddie Arni
              Jul 7 '18 at 0:11











            • When I follow the error message it highlights ' var outcroppings= L.geojson(outcroppings, '

              – Eddie Arni
              Jul 7 '18 at 0:29











            • You cannot call setLatLng() on the layer, but this is what you are trying to do.

              – Stefan
              Sep 9 '18 at 10:13



















            • Nope, that made the feature vanish.. :(

              – Eddie Arni
              Jul 3 '18 at 17:03











            • Do you get a message in the console, or does it just disappear?

              – Josh Beauchamp
              Jul 6 '18 at 17:23











            • I get a mesasage: TypeError: L.geoJson(...).setLatLng is not a function.

              – Eddie Arni
              Jul 7 '18 at 0:11











            • When I follow the error message it highlights ' var outcroppings= L.geojson(outcroppings, '

              – Eddie Arni
              Jul 7 '18 at 0:29











            • You cannot call setLatLng() on the layer, but this is what you are trying to do.

              – Stefan
              Sep 9 '18 at 10:13

















            Nope, that made the feature vanish.. :(

            – Eddie Arni
            Jul 3 '18 at 17:03





            Nope, that made the feature vanish.. :(

            – Eddie Arni
            Jul 3 '18 at 17:03













            Do you get a message in the console, or does it just disappear?

            – Josh Beauchamp
            Jul 6 '18 at 17:23





            Do you get a message in the console, or does it just disappear?

            – Josh Beauchamp
            Jul 6 '18 at 17:23













            I get a mesasage: TypeError: L.geoJson(...).setLatLng is not a function.

            – Eddie Arni
            Jul 7 '18 at 0:11





            I get a mesasage: TypeError: L.geoJson(...).setLatLng is not a function.

            – Eddie Arni
            Jul 7 '18 at 0:11













            When I follow the error message it highlights ' var outcroppings= L.geojson(outcroppings, '

            – Eddie Arni
            Jul 7 '18 at 0:29





            When I follow the error message it highlights ' var outcroppings= L.geojson(outcroppings, '

            – Eddie Arni
            Jul 7 '18 at 0:29













            You cannot call setLatLng() on the layer, but this is what you are trying to do.

            – Stefan
            Sep 9 '18 at 10:13





            You cannot call setLatLng() on the layer, but this is what you are trying to do.

            – Stefan
            Sep 9 '18 at 10:13













            0














            You need to initiate the popup with a layer source (see the Creation section of the popup documentation) and then set its coordinates:



            L.popup(popupOptions,layer).setContent(content).setLatLng(lat_lng)





            share|improve this answer




























              0














              You need to initiate the popup with a layer source (see the Creation section of the popup documentation) and then set its coordinates:



              L.popup(popupOptions,layer).setContent(content).setLatLng(lat_lng)





              share|improve this answer


























                0












                0








                0







                You need to initiate the popup with a layer source (see the Creation section of the popup documentation) and then set its coordinates:



                L.popup(popupOptions,layer).setContent(content).setLatLng(lat_lng)





                share|improve this answer













                You need to initiate the popup with a layer source (see the Creation section of the popup documentation) and then set its coordinates:



                L.popup(popupOptions,layer).setContent(content).setLatLng(lat_lng)






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 9 '18 at 10:17









                StefanStefan

                1,460218




                1,460218






























                    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%2f288229%2fhow-do-i-override-default-popup-anchor-in-leaflet-geojson-polygon%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 Содержание Параметры шины | Стандартизация |...