Giter VIP home page Giter VIP logo

jonnitto.googlemaps's Introduction

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.

Google API

You'll need at least an API Key from Google, and if you want to use Static Maps, you need also a signing secret. Read here how to get these keys
You will need following APIs:

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"
                }
            ]
        }
    ]
};

jonnitto.googlemaps's People

Contributors

daniellienert avatar dependabot[bot] avatar iseries avatar jonnitto avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jonnitto.googlemaps's Issues

Only one map per page is supported

Currently only one map can be placed on a page. If a second map is placed on the same page, the first map won't be initialized

Testet with v3.0.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.