HI
Want to use ZoomToView(x, y, scale, refresh) function in Fusion like its works in Ajax viewer calling this function by creating Invoke Script. Just cant this function working in Fusion. Does someone have working script for it?
Solved! Go to Solution.
Solved by gluckett. Go to Solution.
I created Invoke Script and entered code below:
function ZoomToView(60000, 650000, 20000, refresh) {
//var Fusion = window.top.Fusion;
var mapWidget = Fusion.getWidgetById(mgApiMapWidgetId);
if (mapWidget && mapWidget.isMapLoaded()) {
var extent = mapWidget.getExtentFromPoint(x, y, scale);
mapWidget.setExtents(extent);
}
}
Want to call this function in current mapframe so when I klick Invoke Script button then map are zoomed to desired location. I specified Target frame as "mapFrame".
Still problem get this working, I think I'm missing something.
Try:
function ZoomToView(60000, 650000, 20000, refresh) {
var Fusion = window.top.mapFrame.Fusion;
var mapWidget = Fusion.getWidgetById('Map');
if (mapWidget && mapWidget.isMapLoaded()) {
var extent = mapWidget.getExtentFromPoint(x, y, scale);
mapWidget.setExtents(extent);
}
}
I tried this code. Just copied this code to Studio invoke script window and specified target as mapFrame but still not working.
I add screenshot how its look like in Studo. I'm using open source Mapguide 2.5.
oh, if you are putting it in the INVOKESCRIPT, you don't need the "function"
just put this in your invokescript:
var mapWidget = Fusion.getWidgetById('Map');
if (mapWidget && mapWidget.isMapLoaded()) {
var extent = mapWidget.getExtentFromPoint(60000, 650000, 20000);
mapWidget.setExtents(extent);
}
If you want the PAN to be automatically selected after you zoom put this in the bottom of your INVOKESCRIPT:
var panWidget=Fusion.getWidgetsByType('Pan')[0]; panWidget.uiObj.setActive(true);
Hi,
Is it possible to add marker for this zoomtoview function? if can be done, may i know how to do that.
i have code below and it successfully zoom to the coordinate that i entered. but how do i show marker for the coordinate that i entered?
<html xmlns="http://www.w3.org/1999/xhtml">
<title></title>
<script type="text/javascript" language="javascript" src="../../layers/MapGuide/MapGuideViewerApi.js"></script>
<script type="text/javascript" src="proj4js-1.1.0/lib/proj4js-compressed.js"></script>
<script type="text/javascript">
//Proj4js.defs["EPSG:4326"]="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
var source = new Proj4js.Proj('EPSG:4326');
Proj4js.defs["EPSG:3857"]="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"
var dest = new Proj4js.Proj('EPSG:3857');
function ZoomToView() {
//var Fusion = window.top.Fusion;
var latlong = document.getElementById('longlat').value;
var p = new Proj4js.Point(latlong)
Proj4js.transform(source, dest, p);
var scale = 2500.0003;//20000//15000//10000//5000//2000//1500
var mapWidget = GetFusionMapWidget();
if (mapWidget && mapWidget.isMapLoaded()) {
var extent = mapWidget.getExtentFromPoint(p.x, p.y, scale);
mapWidget.setExtents(extent);
}
}
</script>
<style>
h1{
font-size:20px;
font-family: "Calibri";
}
h2{
font-size:15px;
font-family: "Calibri";
}
</style>
<body>
<div>
<h1> Search Coordinate</h1> <p>
<h2> Enter The Coordinate</h2> <p>
<input type="text" id="longlat" placeholder="In decimal degrees, eg. 102.xxxx, 6.xxxx"><br><br>
<button type="button" onclick="ZoomToView()">Search</button>
</div>
</body>
</html>
thx in advance
-nik-
If the Add the following to your INDEX.HTML for whatever Flexible Web Layout your are using:
<script type="text/javascript" src="../../../layers/MapGuide/MapGuideViewerApi.js"></script>
You can then use the DigitizePoint to put a point there.
For example:
DigitizePoint(OnPointDigitized);