Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/10/2013, 10:38
JUMASOL
 
Fecha de Ingreso: noviembre-2005
Mensajes: 889
Antigüedad: 18 años, 6 meses
Puntos: 8
Inserción de Función

Hola

Trabajaba con una función para insertar urls en una región de un mapa jvectormap, que funcionaba perfectamente:

Código:
(function( $ ){
  var apiParams = {
        colors: 1,
        values: 1,
        backgroundColor: 1,
        scaleColors: 1,
        normalizeFunction: 1
      },
      apiEvents = {
        onLabelShow: 'labelShow',
        onRegionOver: 'regionOver',
        onRegionOut: 'regionOut',
        onRegionClick: 'regionClick',
        onMarkerLabelShow: 'markerLabelShow',
        onMarkerOver: 'markerOver',
        onMarkerOut: 'markerOut',
        onMarkerClick: 'markerClick'
      };
      
  $.fn.vectorMap = function(options) {
    var defaultParams = {
          map: 'world',
          color: '#6383d3',
          hoverColor: '#323637',
          onRegionClick: function(event, code) {
        if (code === 'AM') {
            window.location = 'america'
        }
        else if (code === 'ASI') {
            window.location = 'asia'
        }
        else if (code === 'EUR') {
             window.location = 'europa'
        }
        else if (code === 'ZEU') {
             window.location = 'europa'
        }     
.......
    
    },
          normalizeFunction: 'linear'
        },
        
        map,
        methodName,
        event;
Ahora, por una cuestión que no vamos a comentar, he tenido que cambiar el archivo e instalar otro que incluye los siguientes parámetros:

Código:
}, jvm.WorldMap.maps = {}, jvm.WorldMap.defaultParams = {
    map: "continentes",
    backgroundColor: "#f6f6ff",
    zoomButtons: !0,
    zoomOnScroll: !0,
    zoomMax: 8,
    zoomMin: 1,
    zoomStep: 1.6,
    regionsSelectable: !1,
    markersSelectable: !1,
    bindTouchEvents: !0,
    regionStyle: {
        initial: {
            fill: "#6383d3",
            "fill-opacity": 1,
            stroke: "none",
            "stroke-width": 0,
            "stroke-opacity": 1
        },
        hover: {
            "fill-opacity": .8
        },
        selected: {
            fill: "yellow"
        },
        selectedHover: {}
    },
    markerStyle: {
        initial: {
            fill: "grey",
            stroke: "#505050",
            "fill-opacity": 1,
            "stroke-width": 1,
            "stroke-opacity": 1,
            r: 5
        },
        hover: {
            stroke: "black",
            "stroke-width": 2
        },
        selected: {
            fill: "blue"
        },
        selectedHover: {}
    }
}, jvm.WorldMap.apiEvents = {
    onRegionLabelShow: "regionLabelShow",
    onRegionOver: "regionOver",
    onRegionOut: "regionOut",
    onRegionClick: "regionClick",
    onRegionSelected: "regionSelected",
    onMarkerLabelShow: "markerLabelShow",
    onMarkerOver: "markerOver",
    onMarkerOut: "markerOut",
    onMarkerClick: "markerClick",
    onMarkerSelected: "markerSelected",
    onViewportChange: "viewportChange"
};

El caso es que por más pruebas que hago no puedo incluir los direccionamientos en base a onRegionClick, como los tenía en el otro script:

onRegionClick: function(event, code) {
if (code === 'ZNA') {
window.location = 'america'
}

Estoy seguro de que debe introducirse alguna variación, pero no soy capaz de completarlo aquí.

¿Me podéis decir por dónde tirar?

Gracias.