Javascript, flash and MAPublisher switching issue
Hey.
I am working with Avenza Mapublisher (Adobe Illustrator extension) to create an interactive map .
Exporting a map creates a series of swf flash files, an html file, and some javascript code. The above link shows the unformatted version. As you can see the map is loading very slowly because by default all layers are switched on load. I've tried everything but can't figure out how to control which layers are shown when the map is loaded. Actually all I want is schools, cities and road layer which will be active on boot and the rest will be disabled. Ideally, I would like the remaining pesticide layers to be in the dropdown, so only one can be selected.
I tried setting check checked = "true" to "false", excluded the checkbox entirely and the checkbox was unchecked, but the layer is still active. I think that something must be written to the swf file, which I don't have. Has anyone worked with this program at all. If you're curious, there is a free 2 week trial online test.
So the html file calls
<script src="layerCheckboxes.js" language="javaScript"></script>
and this file is the base variable with all the choices.
var checkboxes = ' \
<input type="checkbox" checked="true" value="Tulare Schools" onClick="swfLayerToggle(value, checked);" />Tulare Schools \
<input type="checkbox" checked="true" value="Towns" onClick="swfLayerToggle(value, checked);" />Towns \
<input type="checkbox" checked="true" value="Major Roads" onClick="swfLayerToggle(value, checked);" />Major Roads \
<input type="checkbox" checked="true" value="County Roads" onClick="swfLayerToggle(value, checked);" />County Roads \
<input type="checkbox" checked="true" value="1_3 Dichloropropene" onClick="swfLayerToggle(value, checked);" />1_3 Dichloropropene \
<input type="checkbox" checked="true" value="Aluminum Phosphide" onClick="swfLayerToggle(value, checked);" />Aluminum Phosphide \
<input type="checkbox" checked="true" value="Chloropicrin" onClick="swfLayerToggle(value, checked);" />Chloropicrin \
<input type="checkbox" checked="true" value="Chlorpyrifos" onClick="swfLayerToggle(value, checked);" />Chlorpyrifos \
<input type="checkbox" checked="true" value="Diazinon" onClick="swfLayerToggle(value, checked);" />Diazinon \
<input type="checkbox" checked="true" value="Fumigants" onClick="swfLayerToggle(value, checked);" />Fumigants \
<input type="checkbox" checked="true" value="Metam Sodium" onClick="swfLayerToggle(value, checked);" />Metam Sodium \
<input type="checkbox" checked="true" value="Methyl Bromide" onClick="swfLayerToggle(value, checked);" />Methyl Bromide \
<input type="checkbox" checked="true" value="Sodium Tetrathiocarbonate" onClick="swfLayerToggle(value, checked);" />Sodium Tetrathiocarbonate \
<input type="checkbox" checked="true" value="Acres Treated" onClick="swfLayerToggle(value, checked);" />Acres Treated \
<input type="checkbox" checked="true" value="Application Rate" onClick="swfLayerToggle(value, checked);" />Application Rate \
<input type="checkbox" checked="true" value="Pesticide Use" onClick="swfLayerToggle(value, checked);" />Pesticide Use \
<input type="checkbox" checked="true" value="Agriculture Use" onClick="swfLayerToggle(value, checked);" />Agriculture Use'
document.write('<form>' + checkboxes + '</form>');
and the swfLayerToggle () function is in a file called checkboxFuntions.js
function getMyApp(appName) {
if (navigator.appName.indexOf ("Microsoft") !=-1) {
return window[appName];
} else {
return document[appName];
}
}
function swfLayerToggle(layer, isOn) {
getMyApp("MAPublisherSWF").swfLayerToggle(layer, isOn);
}
a source to share
I work for Avenza.
Unfortunately what you want to do is not possible with MAPublisher 8.1, however it was added in version 8.2 which is now available. Simply change the Initially Visible option in the Web Map Export dialog box for layers that you do not want to display when the map is loaded.
a source to share