Skip to content

Commit

Permalink
Merge pull request #161 from Indigo744/patch-default-override
Browse files Browse the repository at this point in the history
Update example to show how to override default behavior
  • Loading branch information
neveldo committed Dec 9, 2015
2 parents 03b3adc + d552eac commit 93724a1
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions examples/advanced/multiple_instances.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,33 @@

<script type="text/javascript">
$(function () {

/*
* Override default option example
* Here we override defaultOptions for all instance!
* => We want to set the stroke color different for all of our instance
*/
$.mapael.prototype.defaultOptions.map.defaultArea.attrs.stroke = "#550000";

/*
* Override method example
* Here we override the setTooltip() method for all instance !
* => We want that area having a tooltip appears as red when mouse over
*/
// Save setTooltip function for future use
var baseSetTooltip = $.mapael.prototype.setTooltip;
$.mapael.prototype.setTooltip = function(elem){
// Save ref to Mapael object in self
var self = this;
// Some special processing for "path" element having a tooltip
if (elem.type === "path") {
elem.attrsHover.fill = "#FF0000";
}
// Call base Mapael function
baseSetTooltip.call(self, elem);
};


$(".mapcontainer").mapael({
map: {
name: "france_departments"
Expand All @@ -114,7 +141,6 @@
, defaultArea: {
attrs: {
fill: "#f4f4e8"
, stroke: "#ced8d0"
}
, text: {
attrs: {
Expand Down Expand Up @@ -265,7 +291,6 @@
, defaultArea: {
attrs: {
fill: "#f4f4e8"
, stroke: "#00a1fe"
}
, attrsHover: {
fill: "#a4e100"
Expand Down

0 comments on commit 93724a1

Please sign in to comment.