Create a route (content type) map with gpx file and then points of interest (also mapped points) along that route, how?

Created on 10 April 2024, 7 months ago
Updated 13 May 2024, 6 months ago

I have a route on a map that shows the route for that node it has been uploaded to, this is using a gpx file.

I now want to show many other points of interest along that route using geolocation/geofield which then shows on a single map as the route and then shops, water, accommodation etc along that route.

Then for this single map with all this data to (route and other points of interest) to be shown on each route nodes page.
How is this possible?

At the moment the only way I can think about doing it is having separate geolocation/geofield mapping fields on the route node, the first being GPX Route field, then Shop Location field, Water Location field and so on where I use markers for each map to show these locations.

Then I have to build a block view, select all the mapping fields to show on a map and use contextual filtering to show that map for each node?

One issue I have seen is that I can't add multiple geolocation mapping fields on to one view to show all the different types of points of interest along the route.

Or is there another way to do this?

There has to be a simpler way to do this all on the node I am creating?

💬 Support request
Status

Fixed

Version

1.57

Component

Code

Created by

🇬🇧United Kingdom effortDee

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @effortDee
  • Status changed to Fixed 7 months ago
  • 🇮🇹Italy itamair

    there could be different ways to accomplish what you desire ... and in a more correct than the one you are trying to implement,
    and for different Drupal competence ranks.

    For instance one possible that I would suggest could be the following:

    - use one content type for instance called "Route" where to store a line string route (generated geocoding a GPX file, as in your use case) into a geofield type field called for instance: field_geofield;
    add a taxonomy reference field, called "field_route" where to store (or reference) the name of the specific Route (yes you will generate or need to generate a relevant Routes vocabulary);
    - use one content type for instance called "POI" where to store single Points of Interest into the same geofield still called field_geofield (yes ... you are going to re-use the same geofield of the "Route" content type. Also in this content type add a taxonomy reference field, called "field_route" where you are going to store (or reference) the name of the specific Route (or Routes, because it could be the same POI could be relevant to more than one Route, isn't it?). Also add another taxonomy reference field, called "field_poy_type" that could tag / characterise each POI with a specific "POI Types" vocabulary ...
    - after having accomplished the above 2 tasks, start populating your Routes and POIs, populating each of them field_route with the relevant Route vocabulary term(s). PS: yes, you will have each Route content named and tagged (on the with "field_route" value) probably with the same route name ...

    - generate a Geofield Map View (could be a Leaflet View with the leaflet ,module, or a Google Maps with the Geofield Map, etc.) based on the field_geofield and filtered on the specific "field_route" you want to represent (this could also be accomplished with an exposed filter, and quickly switch to different Routes POIs froth same View) ...
    - and that's it ... in few (and not even too few words);
    ----
    The described above could just be one possible scenario ... but according to your Drupal skills you could also accomplish more refined and powerful ones.
    For instance also a paragraphs types and contents and paragraphs functional logos could be accomplished (given that Geofield fully supports also paragraphs ... ).

    Pretty confident I provided you with valuable inputs ... I wish you good luck and happy Geofield Drupal mapping!

  • Status changed to Needs review 7 months ago
  • Status changed to Fixed 7 months ago
  • 🇮🇹Italy itamair

    I am closing this afternoon days without any review to my support.

  • 🇬🇧United Kingdom effortDee

    Hi Itamar I had the tab open to reply and I do have a question in regards to the GPX route on a map and layering.

    First, thanks so much for the detailed reply, i re-read it a few times to get an understanding of the approach and it is a good one.

    I have seen two other approaches in my quest for the best answer but am yet to find a complete solution.

    I cannot have a gpx route (a line on a map) with geofield using the commonmap setup.

    It will only work with leaflet, but then a leaflet map does not work with a geolocation (i know this is geofield) layer in drupal views.

    So I am yet to find anything that works using geofield to show a route and then on top of that the points of interest all on the same map.

    The route content type and the poi content types definitely work and its a good idea for managing so much content.

    But its impossible to output it at the moment, i spent a good few days trying to get it to work but to no avail because of the mapping issue and laying of maps.

    IP Geolocation and Views for D7 was perfect pre-d8/9/10 but hasn't been updated in years so not available and the geolocation module v4 doesn't actually store a gpx file.

    I have tried so many iterations of geocoding and geofield and as far as I have got is showing the centre of the gpx route with a single pin on a map and then the points of interest all on one map, but no route/line and map.

    Again, i really appreciate your time and thoughts on this.

  • 🇮🇹Italy itamair

    @effortDee it stand under meant that you cannot represent and manage the gpx file / route in the Geofield field, but of course you need to transform you gpx file / content into geofield format (WKT) and that is possible with the Geocoder module and its GPX geocoder provider.

    If you don't know how to do that, well you could get your competences and your way starting from this relevant community comment from the past:
    https://www.drupal.org/project/geocoder/issues/2747193#comment-11829776

    Last (but not least). Please don't mix the geofield naming with the geolocation, as this latter could refer to the geolocation module , that is different from (and not supposed to be mixed with) the geofield module one.

  • 🇮🇹Italy itamair

    Also this new documentation page looks come right in time and purpose on this:
    https://www.drupal.org/docs/extending-drupal/contributed-modules/contrib...

  • 🇩🇰Denmark ressa Copenhagen

    Perfect timing @itamair, your link to that comment was just what I needed to document GPX integration in Geocoder and Geofield, thanks! It allowed me to create Using GPX files with Geocoder and Geofield .

    See also 📌 Document Geofield features in the new documentation system Needs work .

  • 🇬🇧United Kingdom effortDee

    Thanks for getting back.

    I didn't have any issues with the above issue of showing a gpx route using geofield, I had already successfully used FILE / GEOFIELD / GEOCODER and uploaded gpx files, geocoded them in to geofields.

    I understand that geolocation is a separate module and mentioned that because it seems to be the only way to get layering in maps to show multiple content types or paragraphs to show different maps on top of each other.

    I have successfully used geolocation to show gpx routes and points of interest but it does not seem possible with geofield in views.

    At the time of writing i can still find no way to show a gpx route AND points of interest (from a different content type or paragraph type) using gpx file > geocoded > geofield with a view using commonmap and geofield points of interest.

    I can get them to all work separately and embed on nodes but utilising leaflet to show the gpx route (from the geofield) and then geofield points of interest seems impossible and not actually doable.

    And that was my query, do you have any insight to that?

  • 🇮🇹Italy itamair

    Of course you cannot represent a Map only with the Geofield module.
    And you need either the Leaflet drupal module or the Geofield Map one,
    to generate a Geofield based Map View that is using the geofield and is able to show different Contents (nodes or whatever entities) of mixed types/bundles,
    and eventually storing either single POINTs or Routes (from GPX), and even other Geometries (such Polygons), etc ...
    Worth to mention that those views will work very fine also with Exposed Filters based on your Contents / Entities properties (such as type of POI, or Route type/taxonomy, etc.).

    But, once you got how to populate a geofield and make a Drupal (Leaflet or Geofield Map) view around it, everything else relates with your Drupal further skills and creativity (so goes beyond the supporting scope of this issue, imho).

    Last thing: why are trying to use Geofield when it looks that you are able to accomplish all your tasks with the Geolocation module?

  • 🇬🇧United Kingdom effortDee

    I wanted to get it working in Geofield to see which process was better, what differences they offered, which was easier/harder to use and learn both modules.

    I've managed to get it working on multiple sites now with geolocation but no luck with geofield at all.

  • 🇮🇹Italy itamair

    Happy you did it with Geolocation …
    And pretty weird because Geofield is also very good in accomplishing that, in very different and powerful ways.

    Look, for instance, this MtBike trip photographic reportage, with all geo mapping, of course with Geofield stack:

    https://www.geodemocracy.com/via-degli-dei-2024/web/

    I will post soon a thread with more details and foundation hint on that 😉

  • 🇬🇧United Kingdom effortDee

    @itamar I must know how you did that, that is exactly what i've built using geolocation and using paragraphs, one paragraph type for the route gpx file and other paragraph types for the Points of Interest and they all re-use the same geolocation field so they can be used in views.

    What you linked above looks amazing and all using geofield?

    Thanks for your patience with me, i think i have spent 30+ hours now to no avail, maybe its just one small thing i'm not getting right and looking forward to your response.

  • 🇮🇹Italy itamair

    Please have a look to this parent issue that I just created.

    https://www.drupal.org/project/geofield/issues/3444247 💬 Create a route or trip photo reportage with Geofield Stack (with gpx and exif data) Fixed

    You should find your way beyond that ... (or rather go for sponsored support).

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024