Show route/track on OSM map (GPX or KML)

Phoca Maps - displaying maps in Joomla! CMS
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48041
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Show route/track on OSM map (GPX or KML)

Post by Jan »

Hi, implemented in version 3.0.12
https://www.phoca.cz/news/1132-phoca-ma ... 2-released

Jan
If you find Phoca extensions useful, please support the project

Tags:
rogerco
Phoca Member
Phoca Member
Posts: 47
Joined: 18 Sep 2011, 16:17

Re: Show route/track on OSM map (GPX or KML)

Post by rogerco »

That's great, thanks Jan.

I have started work slowly on an OSM only version with some additional features.

Originally I intended to do this simply as a fork from PhocaMaps, but there are so many changes, and much legacy code to update
that I have re-started it as a fresh component. You will be welcome to "Phocarize" this for yourself when it is done -
probably mostly a question of search and replace for my name prefixes with Phoca equivalents. (but some of the code style will be different from your standards)

This is the list of new features that I intend to include - which would also be my personal wishlist for PhocaMaps should you get round to a major revision yourself before I have finished:
  • many-to-many relationship between markers and maps (ie markers can be used on more than one map)
  • many-to-many relationship between tracks and maps (ie a track can be used on more than one map)
    (these two imply a new table for tracks, and tables for the map-tracks links and map-marker links)
  • option settings for individual maps and menus entries as well as globally (eg map type, marker clustering, controls, etc)
  • options settings (global and per item) for tracks and markers (colours, icons etc)
  • new admin views to manage and edit tracks metadata (title, description, date, line style etc) which gets stored in the new table
  • additional site views to list maps, track and markers
  • use joomla categories for maps, tracks and markers
  • use joomla tags for maps, tracks and markers
  • display elevation profile option for tracks
Additional items for further consideration
  • possible new admin view to create or edit track points on a map view. Allow creating of a track from scratch.
  • possible new content plugin to create a map from a single track file (fit to bounds) for embedding in article without having to create a map for it.
  • possible modules to list maps/tracks/markers by date/category/tag with links to display each item
Things I will be removing
  • all google maps support (for me it confuses the issue and makes code more complex and I have no desire to use them)
  • all routing support (I use separate routing applications and websites for different purposes, it is a lot of extra complexity to include support for a routing service and not something I would ever use on my own sites with maps. A wheel not worth re-inventing)
  • the custom icon support - I'd just use fontawesome and be done with it.
  • the kml track support - I only use gpx for preference, all my gps devices produce gpx tracks, strava only supports gpx imports.
    (having said which it would probably be quite easy to add it back using a different leaflet plugin)
Things I will not be doing
  • j4 support. Personally I hate the new backend template for j4 (very poor use of screen real estate) and some of the other changes. There are some improvements but it is a lot of work for not much gain. I have no intention at present of migrating any of my websites to j4 and will continue using j3 for them long after official support ends. I ran into several problems trying to update one of my other components for j4 so I won't be bothering with it until I need to. Probably better to wait a while and then produce native j4 versions as required.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48041
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Show route/track on OSM map (GPX or KML)

Post by Jan »

Hi, Ok, yes, will be great.

Jan
If you find Phoca extensions useful, please support the project
MKfan
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 07 Jul 2021, 22:29

Re: Show route/track on OSM map (GPX or KML)

Post by MKfan »

Hi Jan,
good job, I try the update just Now.

I have a question.

how I can change the color of my KML path?

I think that is a simply code but I not find anything by 2 days to search =((
User avatar
Benno
Phoca Hero
Phoca Hero
Posts: 9196
Joined: 04 Dec 2008, 11:58
Location: Germany
Contact:

Re: Show route/track on OSM map (GPX or KML)

Post by Benno »

Hi,
how I can change the color of my KML path?
Image

Kind regards,
Benno
rogerco
Phoca Member
Phoca Member
Posts: 47
Joined: 18 Sep 2011, 16:17

Re: Show route/track on OSM map (GPX or KML)

Post by rogerco »

Colours don't seem to work for kml tracks - it might be possible but I couldn't get it to work. If anyone knows how to colour a kml layer using leaflet.omnivore then it is line 714 in admin/helpers/phocamapsmaposm.php that needs modifying.

According to the API info linked above omnivore.kml() only takes a single paramter (the filename) whereas for omnivore.gpx() you can add parser options and a custom layer specification which enables you to set a colour.

Perhaps need to make an amendment to the description on the colour box to make it clear that it only applies to gpx tracks. My mistake I should have added that when I found kml colours not working.

A workaround would have to be to convert your kml to gpx... (not what you want to hear, I'm sure - there are online tools to do that)
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48041
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Show route/track on OSM map (GPX or KML)

Post by Jan »

Ok, thank you for the info.
If you find Phoca extensions useful, please support the project
MKfan
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 07 Jul 2021, 22:29

Re: Show route/track on OSM map (GPX or KML)

Post by MKfan »

Thanks for your reply rogerco

I try to convert my KML in GPX and set GPX as Path for my map. unfortunately if I set the parameter "Colors for Tracks (OSM)" to my custom color (#eb4034) I see the same ( stupid ) blue color.

I try as to change the color directly in phocamapsmaposm.php
if (($ext=='.gpx') && $color) {
714 --> $this->output[] = " var customLayer = L.geoJson(null, { style: function(feature) {return {color: '".$color."'}; } });

adding my color instead of the variable but it not work.

I'd like to understand where I'm wrong
rogerco
Phoca Member
Phoca Member
Posts: 47
Joined: 18 Sep 2011, 16:17

Re: Show route/track on OSM map (GPX or KML)

Post by rogerco »

That's interesting - I find that in the published version the track colours are not saving, although they are in my fork. So something has gone wrong in patching my code into the main branch. At a guess it may be simply that "colour" (my spelling) has been changed to "color" (american spelling) somewhere, but not somewhere else. @jan
I'll try and get time later in the week to look at the live code.
MKfan
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 07 Jul 2021, 22:29

Re: Show route/track on OSM map (GPX or KML)

Post by MKfan »

Thanks Rogerco,

would be great,
especially to solve the problems of those who do not see colors well.
blue line on a green background is not the best

if it helps you here the link to my page
ggc.swiss/it/vivi/percorso-marmitte
Post Reply