Justin,
Time to attach your button click code then.
Justin,
Sorry I meant that I want you to attach your button click code that you are using for me to look at.
<?xml version="1.0" encoding="utf-8"?>
<viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:viewer="com.esri.viewer.*">
<fx:Script>
<![CDATA[
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.utils.WebMercatorUtil;
import mx.controls.Alert;
private function createPermalink():void
{
var currentCenter:MapPoint = WebMercatorUtil.webMercatorToGeographic(map.extent.center) as MapPoint;
navigateToURL(new URLRequest(
"index.html?center="
+ myDegreeFormatter.format(currentCenter.y)
+ ","
+ myDegreeFormatter.format(currentCenter.x)
+ "&scale="
+ Math.round(map.scale)), "_blank");
}
private function getURLParameters():Object
{
var result:URLVariables = new URLVariables();
try
{
if (ExternalInterface.available)
{
// Use JavaScript to get the search string from the current browser location.
// Use substring() to remove leading '?'.
// See http://livedocs.adobe.com/flex/3/langref/flash/external/ExternalInterface.html
var search:String = ExternalInterface.call("location.search.substring", 1);
if (search && search.length > 0)
{
result.decode(search);
}
}
}
catch (error:Error)
{
Alert.show(error.toString());
}
return result;
}
private function setMapLocation():void
{
var params:Object = getURLParameters();
if (params["ll"])
{
var latlong:Array = String(params.ll).split(",");
if (latlong.length == 2)
{
map.centerAt(WebMercatorUtil.geographicToWebMercator(new MapPoint(latlong[1], latlong[0])) as MapPoint);
}
}
if (params["scale"])
{
map.scale = params.scale;
}
}
]]>
</fx:Script>
<fx:Declarations>
<mx:NumberFormatter id="myDegreeFormatter"
precision="6"
useThousandsSeparator="true"/>
</fx:Declarations>
<viewer:WidgetTemplate id="passURL" widgetTitle="Pass URL" width="200" height="100">
<s:HGroup id="groupURL">
<s:Button click="createPermalink()"
fontSize="14"
fontWeight="bold"
label="Create a hyperlink"/>
</s:HGroup>
</viewer:WidgetTemplate>
</viewer:BaseWidget>
<?xml version="1.0" encoding="utf-8"?>
<viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:viewer="com.esri.viewer.*">
<fx:Script>
<![CDATA[
import com.esri.ags.geometry.MapPoint;
import com.esri.ags.utils.WebMercatorUtil;
import mx.controls.Alert;
private function createPermalink():void
{
var currentCenter:MapPoint = (map.extent.center) as MapPoint;
navigateToURL(new URLRequest(
"index.html?center="
+ myDegreeFormatter.format(currentCenter.x)
+ ","
+ myDegreeFormatter.format(currentCenter.y)
+ "&scale="
+ Math.round(map.scale)), "_blank");
}
private function getURLParameters():Object
{
var result:URLVariables = new URLVariables();
try
{
if (ExternalInterface.available)
{
// Use JavaScript to get the search string from the current browser location.
// Use substring() to remove leading '?'.
// See http://livedocs.adobe.com/flex/3/langref/flash/external/ExternalInterface.html
var search:String = ExternalInterface.call("location.search.substring", 1);
if (search && search.length > 0)
{
result.decode(search);
}
}
}
catch (error:Error)
{
Alert.show(error.toString());
}
return result;
}
private function setMapLocation():void
{
var params:Object = getURLParameters();
if (params["ll"])
{
var latlong:Array = String(params.ll).split(",");
if (latlong.length == 2)
{
map.centerAt(new MapPoint(latlong[1], latlong[0]));
}
}
if (params["scale"])
{
map.scale = params.scale;
}
}
]]>
</fx:Script>
<fx:Declarations>
<mx:NumberFormatter id="myDegreeFormatter"
precision="0"
useThousandsSeparator="false"/>
</fx:Declarations>
<viewer:WidgetTemplate id="passURL" widgetTitle="Pass URL" width="200" height="100">
<s:HGroup id="groupURL">
<s:Button click="createPermalink()"
fontSize="14"
fontWeight="bold"
label="Create a hyperlink"/>
</s:HGroup>
</viewer:WidgetTemplate>
</viewer:BaseWidget>
var request:URLRequest = new URLRequest("mailto:someone@gmail.com?subject=Map Link&body=index.html?center=" + myDegreeFormatter.format(currentCenter.x) + "," + myDegreeFormatter.format(currentCenter.y) + "&scale=" + Math.round(map.scale))
navigateToURL(request,"_blank");