/ Published in: JavaScript
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`.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(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 ]; } ); }());
URL: https://github.com/cyberhobo/wordpress-geo-mashup/wiki/Javascript-API