NewSignature / us-map

An interactive map of the United States using Raphaël
BSD 2-Clause "Simplified" License
280 stars 184 forks source link

Disable states? #5

Open randalthesecond opened 11 years ago

randalthesecond commented 11 years ago

Is there a way that I can disable certain states?

mlammert commented 11 years ago

From what I can tell there is not a specific way to disable a state. But, what I did was create a stateSpecificStyles and a stateSpecificHoverStyles that were the same fill color of a light gray. So, the state is light gray to begin with and when you hover over it, it is the same light gray thus making it seem disabled.

Hope this works for you!

designer-rohit commented 5 years ago

Yes you can use this code:

// Disable States var States = {'AR': '/arkansas-fire-extinguisher-tag','CA': '/california-fire-extinguisher-tag','FL': '/florida-fire-extinguisher-tag','GA': '/georgia-fire-extinguisher-tag','IL': '/illinois-fire-extinguisher-tag','KS': '/kansas-fire-extinguisher-tag','LA': '/louisiana-fire-extinguisher-tag','MA': '/massachusetts-fire-extinguisher-tag','MT': '/montana-fire-extinguisher-tag','NV': '/nevada-fire-extinguisher-tag','NJ': '/new-jersey-fire-extinguisher-tag','NY': '/new-york-fire-extinguisher-tag','TX': '/texas-fire-extinguisher-tag', };

// for enable states var enableStates = 'AR,CA,FL,GA,IL,KS,LA,MA,MT,NV,NJ,NY,TX'.split(','); var stateSpecificStyles = {}, stateSpecificHoverStyles = {};

// style for specificStates for (var i = 0; i < enableStates.length; i++){ stateSpecificStyles[enableStates[i]] = { fill: '#eef3fc', stroke: '#336699', 'stroke-width': 0.5,cursor: 'default'}; stateSpecificHoverStyles[enableStates[i]] = { fill: '#D5D1FF', stroke: '#336699', 'stroke-width': 1,cursor: 'default'}; } $('#us-map').usmap({ 'stateStyles': { fill: 'white', stroke: '#336699'}, 'stateHoverStyles': { fill: 'white', stroke: '#336699'}, 'stateSpecificStyles': stateSpecificStyles, 'stateSpecificHoverStyles': stateSpecificHoverStyles });

Hope this works for you! All the best 👍