show Map Scale / Distance on Open Layers

New home Forums Pro Add-on General queries show Map Scale / Distance on Open Layers

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #71130
    TeeCee
    Participant

    Hi Team!

    Is it possible to show the map scale / distance on the bottom of the open layer map?

    Regards

    TeeCee

    #71140
    Matthew
    Moderator

    Hi TeeCee,

    Thank you for getting in touch with us, we do appreciate your time.

    Unfortunately the Scale/Distance bar on the OpenLayers map engine is currently not supported within WP Google Maps, however, we may look into adding this in the future. We do apologize for any inconvenience this may have caused.

    I hope this answers your question?

    Should you have any further questions, we are more than happy to answer them.

    Kindest Regards,
    Matthew

    #71142
    TeeCee
    Participant

    Thanks Matthew,

    is there a chance of implementing it myself? Any ideas where to start (i am quite familiar with JS)?

    Regards TeeCee

    #71147
    TeeCee
    Participant

    …Sorry, I forgot: how about the google maps layer? Is it there possible to show the scale/distance-field?

    Regards TeeCee

    #71169
    Matthew
    Moderator

    Hi TeeCee,

    Thank you for your patience on this, I really appreciate it!

    This may be achievable for the “Google Maps” map engine (Maps -> Settings -> General Settings) by using some custom JS code. Thus please may you find our custom JS code in my following Gist link: https://gist.github.com/MatthewCodeCabin/6497b618524628668161bffecda72fab

    Note: This custom JS code is specifically for the Google Maps engine.

    Please may you copy, paste and save the JS code found within my Gist into the “Custom JS” Setting block (Maps -> Settings -> Advanced Settings)?

    Once this has been done, please may you clear your browser cache and confirm if this helps?

    I look forward to your response.

    Kindest Regards,
    Matthew

    #71212
    TeeCee
    Participant

    Yes, that worked. Thanks Matthew!

    But no chance for a code like this for the open layer – engine?

    Regards

    TeeCee

    • This reply was modified 9 months ago by TeeCee.
    #71223
    Matthew
    Moderator

    Hi TeeCee,

    Thank you for your continued time and patience on this, I really appreciate it.

    I have looked into this and it appears that this can be similar in OpenLayers, however, the code needs to be added to the core code of the plugin which means that when you update the plugin the custom added code will be undone/removed. Thus you will need to reimplement the code after each update.

    However nonetheless, if you would like to add the scale bar to the OpenLayers map engine, please follow the steps below:
    1. Navigate to your Plugin Editor (Plugins -> Plugin Editor) or FTP.
    2. If you are using the Plugin Editor, select the “WP Google Maps” plugin in the top right dropdown menu and click the “Select” button.
    3.Navigate through to \wp-content\plugins\wp-google-maps\js\v8\open-layers\ol-map.js.
    4. Search for the following line of code: this.olMap.addControl(new ol.control.FullScreen());.
    5. Below that line of code, add the following custom code:

    /* Add scale line to OL */
    this.olMap.addControl(new ol.control.ScaleLine());

    6. Click the “Save File” button to save your changes.

    Once this has been done, you will need to recompile the files to use the updated files, thus you will need to enable and disable Developer Mode by following the steps below:
    1. Go to the Settings Area by navigating through Maps -> Settings.
    2. Open the “Advanced Settings” tab.
    3. Scroll down and enable the “Developer Mode” settings.
    4. Click the “Save Settings” button.
    5. Go to the Map Editor by navigating through Maps -> Maps -> Edit.
    6. Go back to the Settings Area and disable the “Developer Mode” settings.
    7. Click the “Save Settings” button.

    Once this has been done, please may you clear your browser cache and any site cache if applicable and the scale bar should be displayed on your OpenLayers map.

    Please do let me know if this helps?

    I look forward to your response.

    Kindest Regards,
    Matthew

    #71224
    TeeCee
    Participant

    Your guys are fantastic! That worked. I will keep this in mind, when I do the next update to reimplement it manually.

    Thanks again!

    TeeCee

    #71225
    Matthew
    Moderator

    Hi TeeCee,

    Thank you for getting back to me and for your most valued time, I tremendously appreciate it!

    I am most happy to hear that, and it was my great pleasure assisting you with this.

    Please may you kindly consider reviewing our plugin at https://wordpress.org/support/plugin/wp-google-maps/reviews/#new-post?

    It would really mean the world to me! And if possible, please could I kindly ask you to mention both your name and mine in the review for administrative purposes as this would be a tremendous help?

    Should you ever require any further assistance, I am more than happy to help.

    Have a fantastic day and week further!

    Kindest Regards,
    Matthew

    #71231
    TeeCee
    Participant
    This reply has been marked as private.
    #71233
    Matthew
    Moderator
    This reply has been marked as private.
    #73368
    TeeCee
    Participant

    Hi again,

    is this scale-feature natively supported in the new version 9?

    Regards

    TeeCee

    #73568
    Matthew
    Moderator

    Hi TeeCee,

    Thank you for getting back in touch with us, we do appreciate your time.

    Unfortunately the scale feature is not supported in the new Version, however, we may look into it in the future.

    I hope this answers your question?

    Kindest Regards,
    Matthew

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.