Return to Snippet

Revision: 56900
at September 30, 2014 09:49 by cyberhobo


Updated Code
(function() {
	
	GeoMashup.addAction( 'colorIcon', function( properties, icon, color_name ) {
		// For single category icons use the Geo Mashup color icon names, 
		// but the 24x24 ones in the custom image directory
		icon.image = properties.custom_url_path + '/images/mm_20_' + color_name + '.png';
		icon.iconShadow = '';
		icon.iconSize = [ 24, 24 ];
		icon.iconAnchor = [ 12, 24 ];
		icon.iconInfoWindowAnchor = [ 12, 1 ];
	} );

	GeoMashup.addAction( 'objectIcon', function( properties, obj ) {

		if ( obj.terms.category.length == 0 ) {

			// When there are no categories - mm_20_uncategorised.png
			obj.icon.image = properties.custom_url_path + '/images/mm_20_uncategorised.png';
			obj.icon.iconShadow = '';
			obj.icon.iconSize = [ 24, 24 ];
			obj.icon.iconAnchor = [ 12, 24 ];
			obj.icon.iconInfoWindowAnchor = [ 12, 1 ];

		} else if ( obj.terms.category.length > 1 ) {

			// When there is more than one category - mm_20_mixed.png
			obj.icon.image = properties.custom_url_path + '/images/mm_20_mixed.png';
			obj.icon.iconShadow = '';
			obj.icon.iconSize = [ 24, 24 ];
			obj.icon.iconAnchor = [ 12, 24 ];
			obj.icon.iconInfoWindowAnchor = [ 12, 1 ];

		}
	} );

	GeoMashup.addAction( 'multiObjectMarker', function( properties, marker ) {
	
		// When there is more than one marker assigned to the same location - mm_20_plus.png
		marker.setIcon( properties.custom_url_path + '/images/mm_20_plus.png' );

	} );

	GeoMashup.addAction( 'singleMarkerOptions', function ( properties, options ) {

		// When the map is a single object map with just one marker
		options.icon.image = properties.custom_url_path + '/images/mm_20_uncategorised.png';
		options.icon.iconShadow = '';
		options.icon.iconSize = [ 24, 24 ];
		options.icon.iconAnchor = [ 12, 24 ];
		options.icon.iconInfoWindowAnchor = [ 12, 1 ];

	} );
	
	GeoMashup.addAction( 'glowMarkerIcon', function( properties, glow_options ) {
	    glow_options.icon = properties.custom_url_path + '/images/mm_20_glow.png';
	    glow_options.iconSize = [ 22, 30 ];
	    glow_options.iconAnchor = [ 11, 27 ];
	} );
}());

Revision: 56899
at November 16, 2013 02:53 by cyberhobo


Updated Code
(function() {
	
	GeoMashup.addAction( 'colorIcon', function( properties, icon, color_name ) {
		// For single category icons use the Geo Mashup color icon names, 
		// but the 24x24 ones in the custom image directory
		icon.image = properties.custom_url_path + '/images/mm_20_' + color_name + '.png';
		icon.iconShadow = '';
		icon.iconSize = [ 24, 24 ];
		icon.iconAnchor = [ 12, 24 ];
		icon.iconInfoWindowAnchor = [ 12, 1 ];
	} );

	GeoMashup.addAction( 'objectIcon', function( properties, obj ) {

		if ( obj.terms.category.length == 0 ) {

			// When there are no categories - mm_20_uncategorised.png
			obj.icon.image = properties.custom_url_path + '/images/mm_20_uncategorised.png';
			obj.icon.iconShadow = '';
			obj.icon.iconSize = [ 24, 24 ];
			obj.icon.iconAnchor = [ 12, 24 ];
			obj.icon.iconInfoWindowAnchor = [ 12, 1 ];

		} else if ( obj.terms.category.length > 1 ) {

			// When there is more than one category - mm_20_mixed.png
			obj.icon.image = properties.custom_url_path + '/images/mm_20_mixed.png';
			obj.icon.iconShadow = '';
			obj.icon.iconSize = [ 24, 24 ];
			obj.icon.iconAnchor = [ 12, 24 ];
			obj.icon.iconInfoWindowAnchor = [ 12, 1 ];

		}
	} );

	GeoMashup.addAction( 'multiObjectMarker', function( properties, marker ) {
	
		// When there is more than one marker assigned to the same location - mm_20_plus.png
		marker.setIcon( properties.custom_url_path + '/images/mm_20_plus.png' );

	} );

	GeoMashup.addAction( 'singleMarkerOptions', function ( properties, options ) {

		// When the map is a single object map with just one marker
		options.icon.image = properties.custom_url_path + '/images/mm_20_uncategorised.png';
		options.icon.iconShadow = '';
		options.icon.iconSize = [ 24, 24 ];
		options.icon.iconAnchor = [ 12, 24 ];
		options.icon.iconInfoWindowAnchor = [ 12, 1 ];

	} );
}());

Revision: 56898
at May 3, 2012 10:19 by cyberhobo


Updated Code
(function() {
	
	GeoMashup.addAction( 'colorIcon', function( properties, icon, color_name ) {
		// For single category icons use the Geo Mashup color icon names, 
		// but the 24x24 ones in the custom image directory
		icon.image = properties.custom_url_path + '/images/mm_20_' + color_name + '.png';
		icon.iconShadow = '';
		icon.iconSize = [ 24, 24 ];
		icon.iconAnchor = [ 12, 24 ];
		icon.iconInfoWindowAnchor = [ 12, 1 ];
	} );

	GeoMashup.addAction( 'objectIcon', function( properties, obj ) {

		if ( obj.categories.length == 0 ) {

			// When there are no categories - mm_20_uncategorised.png
			obj.icon.image = properties.custom_url_path + '/images/mm_20_uncategorised.png';
			obj.icon.iconShadow = '';
			obj.icon.iconSize = [ 24, 24 ];
			obj.icon.iconAnchor = [ 12, 24 ];
			obj.icon.iconInfoWindowAnchor = [ 12, 1 ];

		} else if ( obj.categories.length > 1 ) {

			// When there is more than one category - mm_20_mixed.png
			obj.icon.image = properties.custom_url_path + '/images/mm_20_mixed.png';
			obj.icon.iconShadow = '';
			obj.icon.iconSize = [ 24, 24 ];
			obj.icon.iconAnchor = [ 12, 24 ];
			obj.icon.iconInfoWindowAnchor = [ 12, 1 ];

		}
	} );

	GeoMashup.addAction( 'multiObjectMarker', function( properties, marker ) {
	
		// When there is more than one marker assigned to the same location - mm_20_plus.png
		marker.setIcon( properties.custom_url_path + '/images/mm_20_plus.png' );

	} );

	GeoMashup.addAction( 'singleMarkerOptions', function ( properties, options ) {

		// When the map is a single object map with just one marker
		options.icon.image = properties.custom_url_path + '/images/mm_20_uncategorised.png';
		options.icon.iconShadow = '';
		options.icon.iconSize = [ 24, 24 ];
		options.icon.iconAnchor = [ 12, 24 ];
		options.icon.iconInfoWindowAnchor = [ 12, 1 ];

	} );
}());

Revision: 56897
at May 3, 2012 10:16 by cyberhobo


Updated Code
(function() {
	
	GeoMashup.addAction( 'colorIcon', function( properties, icon, color_name ) {
		// For single category icons use the Geo Mashup color icon names, 
		// but the 24x24 ones in the custom image directory
		icon.image = properties.custom_url_path + '/images/mm_20_' + color_name + '.png';
		icon.iconShadow = '';
		icon.iconSize = [ 24, 24 ];
		icon.iconAnchor = [ 12, 24 ];
		icon.iconInfoWindowAnchor = [ 12, 1 ];
	} );

	GeoMashup.addAction( 'objectIcon', function( properties, obj ) {

		if ( obj.categories.length == 0 ) {

			// When there are no categories - mm_20_uncategorised.png
			obj.icon.image = properties.custom_url_path + '/images/mm_20_uncategorised.png';
			obj.icon.iconShadow = '';
			obj.icon.iconSize = [ 24, 24 ];
			obj.icon.iconAnchor = [ 12, 24 ];
			obj.icon.iconInfoWindowAnchor = [ 12, 1 ];

		} else if ( obj.categories.length > 1 ) {

			// When there is more than one category - mm_20_mixed.png
			obj.icon.image = properties.custom_url_path + '/images/mm_20_mixed.png';
			obj.icon.iconShadow = '';
			obj.icon.iconSize = [ 24, 24 ];
			obj.icon.iconAnchor = [ 12, 24 ];
			obj.icon.iconInfoWindowAnchor = [ 12, 1 ];

		}
	} );

	GeoMashup.addAction( 'multiObjectMarker', function( properties, marker ) {
	
		// When there is more than one marker assigned to the same location - mm_20_plus.png
		marker.setIcon( properties.custom_url_path + '/images/mm_20_plus.png' );

	} );

	GeoMashup.addAction( 'singleMarkerOptions', function ( properties, options ) {

		// When the map is a single object map with just one marker
		obj.icon.image = properties.custom_url_path + '/images/mm_20_uncategorised.png';
		options.icon.iconShadow = '';
		options.icon.iconSize = [ 24, 24 ];
		options.icon.iconAnchor = [ 12, 24 ];
		options.icon.iconInfoWindowAnchor = [ 12, 1 ];

	} );
}());

Revision: 56896
at May 3, 2012 10:14 by cyberhobo


Updated Code
(function() {
	
	GeoMashup.addAction( 'colorIcon', function( properties, icon, color_name ) {
		// For single category icons use the Geo Mashup color icon names, 
		// but the 24x24 ones in the custom image directory
		icon.image = properties.custom_url_path + '/images/mm_20_' + color_name + '.png';
		icon.iconShadow = '';
		icon.iconSize = [ 24, 24 ];
		icon.iconAnchor = [ 12, 24 ];
		icon.iconInfoWindowAnchor = [ 12, 1 ];
	} );

	GeoMashup.addAction( 'objectIcon', function( properties, obj ) {

		if ( obj.categories.length == 0 ) {

			// When there are no categories - mm_20_uncategorised.png
			obj.icon.image = properties.custom_url_path + '/images/mm_20_uncategorised.png';
			obj.icon.iconShadow = '';
			obj.icon.iconSize = [ 24, 24 ];
			obj.icon.iconAnchor = [ 12, 24 ];
			obj.icon.iconInfoWindowAnchor = [ 12, 1 ];

		} else if ( obj.categories.length > 1 ) {

			// When there is more than one category - mm_20_mixed.png
			obj.icon.image = properties.custom_url_path + '/images/mm_20_mixed.png';
			obj.icon.iconShadow = '';
			obj.icon.iconSize = [ 24, 24 ];
			obj.icon.iconAnchor = [ 12, 24 ];
			obj.icon.iconInfoWindowAnchor = [ 12, 1 ];

		}
	} );

	GeoMashup.addAction( 'multiObjectMarker', function( properties, marker ) {
	
		// When there is more than one marker assigned to the same location - mm_20_plus.png
		marker.setIcon( properties.custom_url_path + '/images/mm_20_plus.png' );

	} );

	GeoMashup.addAction( 'singleMarkerOptions', function ( properties, options ) {

		// Use the Google 'A' icon instead of the default for single object maps
		options.icon.image = 'http://www.google.com/mapfiles/markerA.png';
		options.icon.iconShadow = '';
		options.icon.iconSize = [ 24, 24 ];
		options.icon.iconAnchor = [ 12, 24 ];
		options.icon.iconInfoWindowAnchor = [ 12, 1 ];

	} );
}());

Revision: 56895
at April 20, 2012 10:23 by cyberhobo


Initial Code
(function() {
	
	GeoMashup.addAction( 'colorIcon', function( properties, icon, color_name ) {
		// For single category icons use the Geo Mashup color icon names, 
		// but the 24x24 ones in the custom image directory
		icon.image = properties.custom_url_path + '/images/mm_20_' + color_name + '.png';
		icon.iconShadow = '';
		icon.iconSize = [ 24, 24 ];
		icon.iconAnchor = [ 12, 24 ];
		icon.iconInfoWindowAnchor = [ 12, 1 ];
	} );

	GeoMashup.addAction( 'objectIcon', function( properties, obj ) {

		if ( obj.categories.length == 0 ) {

			// When there are no categories - mm_20_uncategorised.png
			obj.icon.image = properties.custom_url_path + '/images/mm_20_uncategorised.png';
			obj.icon.iconShadow = '';
			obj.icon.iconSize = [ 24, 24 ];
			obj.icon.iconAnchor = [ 12, 24 ];
			obj.icon.iconInfoWindowAnchor = [ 12, 1 ];

		} else if ( obj.categories.length > 1 ) {

			// When there is more than one category - mm_20_mixed.png
			obj.icon.image = properties.custom_url_path + '/images/mm_20_mixed.png';
			obj.icon.iconShadow = '';
			obj.icon.iconSize = [ 24, 24 ];
			obj.icon.iconAnchor = [ 12, 24 ];
			obj.icon.iconInfoWindowAnchor = [ 12, 1 ];

		}
	} );

	GeoMashup.addAction( 'multiObjectMarker', function( properties, marker ) {
	
		// When there is more than one marker assigned to the same location - mm_20_plus.png
		marker.setIcon( properties.custom_url_path + '/images/mm_20_plus.png' );

	} );

}());

Initial URL
https://github.com/cyberhobo/wordpress-geo-mashup/wiki/Javascript-API

Initial Description
Some common custom javascript for customizing geo mashup map markers for any map provider. The marker images used are 24 x 24 pixels, anchored at the bottom center, with no shadow. You'd put images in `wp_content/plugins/geo-mashup-custom/images` to use your own images with this snippet. The example images are the old small markers and are still in the distributed plugin, you can use them by replacing `custom_url_path` with just `url_path`.

Initial Title
WordPress Geo Mashup Mapstraction Custom Markers

Initial Tags


Initial Language
JavaScript