Possible to change anchor point for popup without marker?












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


Preciate som help! Thanks!










share|improve this question







New contributor




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

























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


    Preciate som help! Thanks!










    share|improve this question







    New contributor




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























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


      Preciate som help! Thanks!










      share|improve this question







      New contributor




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












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


      Preciate som help! Thanks!







      leaflet openstreetmap popup






      share|improve this question







      New contributor




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











      share|improve this question







      New contributor




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









      share|improve this question




      share|improve this question






      New contributor




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









      asked 3 hours ago









      3D-kreativ3D-kreativ

      1084




      1084




      New contributor




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





      New contributor





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






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






















          1 Answer
          1






          active

          oldest

          votes


















          2















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




          Yes.



          This is a case of RTFM. 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
























          • Works perfect! Thanks!

            – 3D-kreativ
            3 hours ago











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


          }
          });






          3D-kreativ 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%2f312542%2fpossible-to-change-anchor-point-for-popup-without-marker%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









          2















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




          Yes.



          This is a case of RTFM. 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
























          • Works perfect! Thanks!

            – 3D-kreativ
            3 hours ago
















          2















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




          Yes.



          This is a case of RTFM. 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
























          • Works perfect! Thanks!

            – 3D-kreativ
            3 hours ago














          2












          2








          2








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




          Yes.



          This is a case of RTFM. 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.



          This is a case of RTFM. 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










          answered 3 hours ago









          IvanSanchezIvanSanchez

          5,9181619




          5,9181619













          • Works perfect! Thanks!

            – 3D-kreativ
            3 hours ago



















          • Works perfect! Thanks!

            – 3D-kreativ
            3 hours ago

















          Works perfect! Thanks!

          – 3D-kreativ
          3 hours ago





          Works perfect! Thanks!

          – 3D-kreativ
          3 hours ago










          3D-kreativ is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          3D-kreativ is a new contributor. Be nice, and check out our Code of Conduct.













          3D-kreativ is a new contributor. Be nice, and check out our Code of Conduct.












          3D-kreativ 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%2f312542%2fpossible-to-change-anchor-point-for-popup-without-marker%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

          Callistus I

          Tabula Rosettana

          How to label and detect the document text images