Skip to content

Instantly share code, notes, and snippets.

@DylanCodeCabin
Created November 28, 2022 06:21
Show Gist options
  • Save DylanCodeCabin/21d0646640d03ae7d051548d89fea8ff to your computer and use it in GitHub Desktop.
Save DylanCodeCabin/21d0646640d03ae7d051548d89fea8ff to your computer and use it in GitHub Desktop.
const customMapId = 1;
/* An array with objects, each object represents a polygon */
const customPolygonData = [
{
description : "This is an example",
fillcolor: "#808080",
linecolor: "#666666",
lineopacity: "0.5",
linethickness: "3",
map_id: customMapId,
ohfillcolor: "#333333",
ohlinecolor: "#333333",
ohopacity: "0.7",
opacity: "0.5",
polydata: [
{
"lat":"41.973052569247955",
"lng":"-120.2621297558594"
},
{
"lat":"42.03836216459711",
"lng":"-114.0218953808594"
},
{
"lat":"34.16782039785561",
"lng":"-113.6703328808594"
},
{
"lat":"35.32328519432706",
"lng":"-115.0765828808594"
},
{
"lat":"38.69117201150283",
"lng":"-119.9984578808594"
}
],
polyname: "Example",
title: "Example",
}
];
jQuery(function($){
$(document.body).on('markersplaced.wpgmza', () => {
const map = WPGMZA.getMapByID(customMapId);
if(map){
for(let i in customPolygonData){
const data = customPolygonData[i];
const instance = WPGMZA.Polygon.createInstance(data);
map.addPolygon(instance);
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment