Created
September 10, 2012 20:58
-
-
Save cyberhobo/3693804 to your computer and use it in GitHub Desktop.
Some common custom javascript for customizing geo mashup map markers for Mapstraction map providers (any other than Google v2). The marker images used are 24 x 24 pixels, anchored at the bottom center, with no shadow. #wordpress-geo-mashup #geo-mashup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 ]; | |
} ); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment