New home › Forums › Pro Add-on › General queries › show Map Scale / Distance on Open Layers
- This topic has 12 replies, 2 voices, and was last updated 11 months, 3 weeks ago by Matthew.
-
AuthorPosts
-
November 9, 2021 at 7:08 pm #71130TeeCeeParticipant
Hi Team!
Is it possible to show the map scale / distance on the bottom of the open layer map?
Regards
TeeCee
November 10, 2021 at 7:09 am #71140MatthewModeratorHi 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,
MatthewNovember 10, 2021 at 8:49 am #71142TeeCeeParticipantThanks Matthew,
is there a chance of implementing it myself? Any ideas where to start (i am quite familiar with JS)?
Regards TeeCee
November 10, 2021 at 1:52 pm #71147TeeCeeParticipant…Sorry, I forgot: how about the google maps layer? Is it there possible to show the scale/distance-field?
Regards TeeCee
November 12, 2021 at 7:07 am #71169MatthewModeratorHi 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,
MatthewNovember 12, 2021 at 1:42 pm #71212TeeCeeParticipantYes, that worked. Thanks Matthew!
But no chance for a code like this for the open layer – engine?
Regards
TeeCee
- This reply was modified 1 year, 6 months ago by TeeCee.
November 15, 2021 at 8:38 am #71223MatthewModeratorHi 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,
MatthewNovember 15, 2021 at 11:47 am #71224TeeCeeParticipantYour guys are fantastic! That worked. I will keep this in mind, when I do the next update to reimplement it manually.
Thanks again!
TeeCee
November 15, 2021 at 11:49 am #71225MatthewModeratorHi 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,
MatthewNovember 15, 2021 at 2:38 pm #71231TeeCeeParticipantThis reply has been marked as private.November 15, 2021 at 3:05 pm #71233MatthewModeratorThis reply has been marked as private.June 19, 2022 at 6:02 pm #73368TeeCeeParticipantHi again,
is this scale-feature natively supported in the new version 9?
Regards
TeeCee
June 20, 2022 at 10:56 am #73568MatthewModeratorHi 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 -
AuthorPosts
- You must be logged in to reply to this topic.