Google Maps Or Openstreet Maps Customization - Question | JoomShaper

Google Maps Or Openstreet Maps Customization

S

serge

SP Page Builder 4 years ago

Hello, I would like to add some customization to the maps (Google or openstreet no matter). Like:

  1. itinerary between two points
  2. Draw circles around a selected point.

Is it possible and how?

Thank you.

0
8 Answers
Ariba
Ariba
Accepted Answer
Support Agent 4 years ago #18949

Hello

Thank you for your query. If you want to draw circles around a selected point, you can try following the code in this link https://developers.google.com/maps/documentation/javascript/examples/circle-simple#maps_circle_simple-typescript

0
S
serge
Accepted Answer
4 years ago #18952

Thank you Ariba! But where to put this javascript code, how to access to a particular map on the particular page of SP Page builder?

0
Ariba
Ariba
Accepted Answer
Support Agent 4 years ago #18957

You are most welcome.

Kindly check the screenshot below:

in_head.png

You can insert custom Javascript code in the Custom Code section if you are using Helix framework.

0
S
serge
Accepted Answer
4 years ago #18981

But I'm not using helix ultimate.

0
Paul Frankowski
Paul Frankowski
Accepted Answer
Senior Staff 4 years ago #18991

Hi, In that case read tip "How to use custom JavaScript" from our documenation for SPPB Pro

https://www.joomshaper.com/documentation/sp-page-builder/sp-page-builder-3/how-to-tips

this is universal method, that works in all templates

0
S
serge
Accepted Answer
4 years ago #19018

Should I link the javascript code to the #id of the native SPPage builder google map : sppb-addon-gmap-1622223646265

Or I should create a custom module with all google map's html and javascript and then publish it in SpPage builder?

0
S
serge
Accepted Answer
4 years ago #19026

I've put this code into the js file, but nothing happens. I use #id of the existing Pagebulder google map.

        const citymap = {
    paris: {
      center: { lat: 48.85648185039337, lng: 2.3498061650287094 },
      population: 2714856,
    },
  };

  function initMap() {
    // Create the map.
    const map = new google.maps.Map(document.getElementById("**sppb-addon-gmap-1622293635357**"), {
      zoom: 4,
      center: { lat: 48.85648185039337, lng: 2.3498061650287094 },
      mapTypeId: "roadmap",
    });

    // Construct the circle for each value in citymap.
    // Note: We scale the area of the circle based on the population.
    for (const city in citymap) {
      // Add the circle for this city to the map.
      const cityCircle = new google.maps.Circle({
        strokeColor: "#FF0000",
        strokeOpacity: 0.8,
        strokeWeight: 2,
        fillColor: "#FF0000",
        fillOpacity: 0.35,
        map,
        center: citymap[city].center,
        radius: Math.sqrt(citymap[city].population) * 100,
      });
    }
  }
0
Paul Frankowski
Paul Frankowski
Accepted Answer
Senior Staff 4 years ago #19037

We can give only general tips, sorry but we don't help with code customization, it's against Support Policy rules.

Probably in your case you have to ask developer (freelancer) for help.

0