burnbright/silverstripe-widget-googlemap

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

A simple, non-bloated, google maps SilverStripe widget.

dev-master 2016-01-13 01:41 UTC

This package is auto-updated.

Last update: 2021-09-24 13:27:16 UTC


README

A google map widget for SilverStripe. This widget has intentially been made simple, leaving out any bloat.

CMS options include:

  • Latitude / Longitude
  • Zoom Level
  • Disable Controls

Customising the map

You can customise the map via javascript, by accessing stored references to each map, found in the global variable GoogleMapWidget.maps.

For example, to style all maps grey, pan left 200px, and add a custom marker:

(function($) {
	$(document).ready(function() {
		if(typeof GoogleMapWidget != 'undefined'){ //if widget is present
			var style = [
				{
					"stylers": [
						{ "saturation": -100}
					]
				}
			];
			var customMapType = new google.maps.StyledMapType(style);
			var map;
			for (var i in GoogleMapWidget.maps) {
				map = GoogleMapWidget.maps[i]
				map.mapTypes.set("STYLED_MAP", customMapType);
				map.setOptions({
					mapTypeId: "STYLED_MAP"
				});
				map.panBy(200,0);
				map.marker.setIcon("mysite/images/map_marker.png");
			};
		}
	});
})(jQuery);

Create a custom map styles here: http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html