Support

Account

Home Forums General Issues Custom field in JS map

Solved

Custom field in JS map

  • Hi everyone,

    I have a js google map which links markers to wordpress post permalinks and I’d like to replace permalinks with another link written in a custom field.

    Is it possible?

    This is the code

    if ( ! _item.location )
    return;

    if ( $.isArray( _item.location ) && _item.location[0] && _item.location[1] ) {
    $map.gmap( ‘addMarker’, {
    ‘position’ : new google.maps.LatLng( _item.location[0], _item.location[1] ),
    ‘bounds’ : jobifyMapSettings.center.long && ( jobifyMapSettings.zoom != ‘auto’ ) ? false : true,
    ‘animation’ : google.maps.Animation.DROP,
    ‘title’ : _item.title,
    ‘tooltip’ : false
    }, function(map, marker) {
    new Tooltip({
    marker : marker,
    content : _item.title,
    cssClass : ‘map-tooltip’
    });
    }).click(function(event, map) {
    window.location = _item.permalink;
    });
    } else {
    convertAddress( _item.location, function( latlong ) {
    $map.gmap( ‘addMarker’, {
    ‘position’ : latlong,
    ‘bounds’ : jobifyMapSettings.center.long && ( jobifyMapSettings.zoom != ‘auto’ ) ? false : true,
    ‘animation’ : google.maps.Animation.DROP,
    ‘title’ : _item.title,
    ‘tooltip’ : false
    }, function(map, marker) {
    new Tooltip({
    marker : marker,
    content : _item.title,
    cssClass : ‘map-tooltip’
    });
    }).click(function(event, map) {
    window.location = _item.permalink;
    });
    }, _item );
    }

    ________

    Thank you in advance
    Francesco

  • Hi @56kommunikation

    Your code shows a small snapshot of the entire picture. It looks like all the market data comes from a variable called _item.

    I am not sure how this variable exists, perhaps it is within a loop of items?
    On top of that, I don’t know where _item gets any of it’s data. Perhaps from a JSON feed? Perhaps from elements in the DOM using data- tags?

    You will need to find where the item data comes from, and find a way to customize the PHP which renders it.

    Due to the nature of this question, I won’t be able to provide much help, but perhaps another web developer could provide some freelance services to you?

    Thanks
    E

  • Hi Elliot,

    I kindly thank you for your answer and availability. I solved the problem myself, variable was in a php file through JSON function.

    You are a master!

    Thank you
    Best
    Francesco

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

The topic ‘Custom field in JS map’ is closed to new replies.