Home Forums Front-end Issues Google map location


Google map location

  • Is there a way of changing the default pin graphic, what I need to is change the graphic between 2 versions depending on what type of location it is.

    I can change it across all locations but i need to be per location.

    Would be cool if this could be done in the ‘data’ attributes when you add markers.

    Many thanks


  • Just sorted it, I really love this plugin.

  • how did you sort it?

  • Here is my add_marker() function:

    function add_marker( $marker, map ) {
    	var iconBase = '<?php echo get_bloginfo('template_directory')  ;?>/images/';
    	// var
    	var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );
    	// create marker
    	var marker = new google.maps.Marker({
    		position	: latlng,
    		map			: map,
    		icon: iconBase + $marker.attr('data-pin') + '-pin.png'
    	// add to array
    	map.markers.push( marker );
    	// if marker contains HTML, add it to an infoWindow
    	if( $marker.html() )
    		// create info window
    		var infowindow = new google.maps.InfoWindow({
    			content		: $marker.html()
    		// show info window when marker is clicked
    		google.maps.event.addListener(marker, 'click', function() {
    map, marker );

    “data-pin” comes from a data element generated by WordPress category.

    Hope that helps.


Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Google map location’ is closed to new replies.