iseries / Jonnitto.GoogleMaps

Google Maps as Content Element in Neos.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Latest Stable Version Total Downloads License GitHub forks GitHub stars GitHub watchers GitHub followers Follow Jon on Twitter

Jonnitto.GoogleMaps Package for Neos CMS

With this package you can include Google Maps and / or Streetview and even Static Maps in a simple way into Neos CMS. Contributions are very welcome!

Installation

Most of the time you have to make small adjustments to a package (e.g. configuration in Settings.yaml). Because of that, it is important to add the corresponding package to the composer from your theme package. Mostly this is the site packages located under Packages/Sites/. To install it correctly go to your theme package (e.g.Packages/Sites/Foo.Bar) and run following command:

composer require jonnitto/googlemaps --no-update

The --no-update command prevent the automatic update of the dependencies. After the package was added to your theme composer.json, go back to the root of the Neos installation and run composer update. Et voilĂ ! Your desired package is now installed correctly.

Modification

  • To set the options, use the global variable GoogleMapsOptions
  • To set the marker pin, use the global variable GoogleMapsPin
  • To include functions, use GoogleMapsFunction

In the Javscript of the package, following code gets executed:

if (typeof GoogleMapsPin === "string") {
    marker.icon = GoogleMapsPin;
} else if (typeof GoogleMapsPin === "object") {
    extend(marker, GoogleMapsPin);
}
        
if (typeof GoogleMapsFunction === "function") {
    GoogleMapsFunction();
}

if (typeof GoogleMapsOptions === "object") {
    extend(object.Map.options, GoogleMapsOptions);
}

if (typeof GoogleStreetviewOptions === "object") {
    extend(object.Streetview.options, GoogleStreetviewOptions);
}

Like that, you can do almost everything with the map.

Example: Custom pin

window.GoogleMapsFunction () => {
    window.GoogleMapsPin = {
        icon: {
            url: '/YOUR/PATH/TO/THE/MapPin.png',
            anchor: new google.maps.Point(10, 50),
            scaledSize: new google.maps.Size(22, 40)
        }
    };
}

or

window.GoogleMapsPin = '/YOUR/PATH/TO/THE/MapPin.png';

Example: Custom map options

window.GoogleMapsOptions = {
    streetViewControl: false,
    mapTypeControl: false,
    scrollwheel: false,
    styles: [
        {
            "elementType": "geometry",
            "stylers": [
                {
                    "color": "#f5f5f5"
                }
            ]
        }
    ]
};

License

Licensed under MIT, see LICENSE

About

Google Maps as Content Element in Neos.io

License:MIT License


Languages

Language:JavaScript 57.2%Language:PHP 31.2%Language:CSS 11.6%