Changing anchor point for popup without marker using Leaflet?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1















Is it possible to change the position of the anchor point for the popup without using markers?



I was testing with this example. This code shows a popup, but I want to adjust the position of the anchor because it gets in front of a marker.



 var popup = L.popup()
.setLatLng([testLat, testLng])
.setContent("<div.... </div>")
.openOn(map);


I already has markers and popups on the map and the position for those I get from a JSON-string. These popups opens when I click on a marker, but now I just want a simple popup to be visible when the map has loaded. I have tried to open one of the popup that I'm already have, but that does not seems to work. If that had worked, I didn't need to use a extra popup and change the anchor point for that popup because that is already done. This is a part of my code where I create the markers and bind them with popups.



Is there a way to open one of those popup instead?



// Add markers
for (i = 0; i < mapPos.length; i++)
marker = new L.marker([mapPos[i]["lat"],mapPos[i]["lng"]], icon: numbers[1]).addTo(map).bindPopup("<div>.... </div>");










share|improve this question




























    1















    Is it possible to change the position of the anchor point for the popup without using markers?



    I was testing with this example. This code shows a popup, but I want to adjust the position of the anchor because it gets in front of a marker.



     var popup = L.popup()
    .setLatLng([testLat, testLng])
    .setContent("<div.... </div>")
    .openOn(map);


    I already has markers and popups on the map and the position for those I get from a JSON-string. These popups opens when I click on a marker, but now I just want a simple popup to be visible when the map has loaded. I have tried to open one of the popup that I'm already have, but that does not seems to work. If that had worked, I didn't need to use a extra popup and change the anchor point for that popup because that is already done. This is a part of my code where I create the markers and bind them with popups.



    Is there a way to open one of those popup instead?



    // Add markers
    for (i = 0; i < mapPos.length; i++)
    marker = new L.marker([mapPos[i]["lat"],mapPos[i]["lng"]], icon: numbers[1]).addTo(map).bindPopup("<div>.... </div>");










    share|improve this question


























      1












      1








      1








      Is it possible to change the position of the anchor point for the popup without using markers?



      I was testing with this example. This code shows a popup, but I want to adjust the position of the anchor because it gets in front of a marker.



       var popup = L.popup()
      .setLatLng([testLat, testLng])
      .setContent("<div.... </div>")
      .openOn(map);


      I already has markers and popups on the map and the position for those I get from a JSON-string. These popups opens when I click on a marker, but now I just want a simple popup to be visible when the map has loaded. I have tried to open one of the popup that I'm already have, but that does not seems to work. If that had worked, I didn't need to use a extra popup and change the anchor point for that popup because that is already done. This is a part of my code where I create the markers and bind them with popups.



      Is there a way to open one of those popup instead?



      // Add markers
      for (i = 0; i < mapPos.length; i++)
      marker = new L.marker([mapPos[i]["lat"],mapPos[i]["lng"]], icon: numbers[1]).addTo(map).bindPopup("<div>.... </div>");










      share|improve this question
















      Is it possible to change the position of the anchor point for the popup without using markers?



      I was testing with this example. This code shows a popup, but I want to adjust the position of the anchor because it gets in front of a marker.



       var popup = L.popup()
      .setLatLng([testLat, testLng])
      .setContent("<div.... </div>")
      .openOn(map);


      I already has markers and popups on the map and the position for those I get from a JSON-string. These popups opens when I click on a marker, but now I just want a simple popup to be visible when the map has loaded. I have tried to open one of the popup that I'm already have, but that does not seems to work. If that had worked, I didn't need to use a extra popup and change the anchor point for that popup because that is already done. This is a part of my code where I create the markers and bind them with popups.



      Is there a way to open one of those popup instead?



      // Add markers
      for (i = 0; i < mapPos.length; i++)
      marker = new L.marker([mapPos[i]["lat"],mapPos[i]["lng"]], icon: numbers[1]).addTo(map).bindPopup("<div>.... </div>");







      leaflet openstreetmap popup






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 17 at 19:24









      PolyGeo

      53.7k1781243




      53.7k1781243










      asked Feb 17 at 13:40









      3D-kreativ3D-kreativ

      1084




      1084




















          1 Answer
          1






          active

          oldest

          votes


















          3















          Is it possible to change the position of the anchor point for the popup without using markers?




          Yes.



          If you read the API documentation for L.Popup, you should notice it inherits options from L.DivOverlay. One of those options is offset:




          offset



          type Point



          default Point(0, 7)



          The offset of the popup position. Useful to control the anchor of the popup when opening it on some overlays.




          Therefore, you can do something like:



          var popup = L.popup( offset: L.point(20, 30) )
          .setLatLng([testLat, testLng])
          .setContent("<div.... </div>")
          .openOn(map);





          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%2f312542%2fchanging-anchor-point-for-popup-without-marker-using-leaflet%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









            3















            Is it possible to change the position of the anchor point for the popup without using markers?




            Yes.



            If you read the API documentation for L.Popup, you should notice it inherits options from L.DivOverlay. One of those options is offset:




            offset



            type Point



            default Point(0, 7)



            The offset of the popup position. Useful to control the anchor of the popup when opening it on some overlays.




            Therefore, you can do something like:



            var popup = L.popup( offset: L.point(20, 30) )
            .setLatLng([testLat, testLng])
            .setContent("<div.... </div>")
            .openOn(map);





            share|improve this answer





























              3















              Is it possible to change the position of the anchor point for the popup without using markers?




              Yes.



              If you read the API documentation for L.Popup, you should notice it inherits options from L.DivOverlay. One of those options is offset:




              offset



              type Point



              default Point(0, 7)



              The offset of the popup position. Useful to control the anchor of the popup when opening it on some overlays.




              Therefore, you can do something like:



              var popup = L.popup( offset: L.point(20, 30) )
              .setLatLng([testLat, testLng])
              .setContent("<div.... </div>")
              .openOn(map);





              share|improve this answer



























                3












                3








                3








                Is it possible to change the position of the anchor point for the popup without using markers?




                Yes.



                If you read the API documentation for L.Popup, you should notice it inherits options from L.DivOverlay. One of those options is offset:




                offset



                type Point



                default Point(0, 7)



                The offset of the popup position. Useful to control the anchor of the popup when opening it on some overlays.




                Therefore, you can do something like:



                var popup = L.popup( offset: L.point(20, 30) )
                .setLatLng([testLat, testLng])
                .setContent("<div.... </div>")
                .openOn(map);





                share|improve this answer
















                Is it possible to change the position of the anchor point for the popup without using markers?




                Yes.



                If you read the API documentation for L.Popup, you should notice it inherits options from L.DivOverlay. One of those options is offset:




                offset



                type Point



                default Point(0, 7)



                The offset of the popup position. Useful to control the anchor of the popup when opening it on some overlays.




                Therefore, you can do something like:



                var popup = L.popup( offset: L.point(20, 30) )
                .setLatLng([testLat, testLng])
                .setContent("<div.... </div>")
                .openOn(map);






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 17 at 19:25









                PolyGeo

                53.7k1781243




                53.7k1781243










                answered Feb 17 at 13:49









                IvanSanchezIvanSanchez

                6,0531619




                6,0531619



























                    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%2f312542%2fchanging-anchor-point-for-popup-without-marker-using-leaflet%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

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?