[OpenLayers-Users] viewing an external webpage within belowopenlayers map

Robert Sanson SansonR at asurequality.com
Mon Oct 5 15:46:05 EDT 2009


Hi Emmanuel
 
OK - here is some code from an application we have developed:
 
Here is the code for clicking on a map and getting a response:
 
map.events.register('click', map, function (e) {
                  var xys = map.getLonLatFromViewPortPx(e.xy);
                  easting = xys.lon;
                  northing = xys.lat;
                  OpenLayers.Util.getElement('coords').innerHTML = "<strong>x:</strong>" + parseInt(easting) + " <strong>y:</strong>" + parseInt(northing);
                  //added 12th Feb
                  var tempgeom = new OpenLayers.Geometry.Point(easting,northing);
                  //now re-projection to WGS84
                  var src = new OpenLayers.Projection('EPSG:2193');
                  var dest = new OpenLayers.Projection('EPSG:4326'); 
                  OpenLayers.Projection.transform(tempgeom, src, dest); 
                  longitude = tempgeom.x;
                  latitude = tempgeom.y;
                  var bbox1 = easting - 10;
                  var bbox2 = northing - 10;
                  var bbox3 = easting + 10;
                  var bbox4 = northing + 10;
                  if ((mode == "qry") || (mode == "allocate") || (mode == "deallocate")) {
                    var parcel = "http://esri-arcims/wmsconnector/com.esri.wms.Esrimap?servicename=sansonr_crs&version=1.1.1&request=GetFeatureInfo&QUERY_LAYERS=2&INFO_FORMAT=text/plain&SRS=EPSG:2193&BBOX=" + bbox1 + "," + bbox2 + "," + bbox3 + "," + bbox4 + "&WIDTH=20&HEIGHT=20&X=10&Y=10";
                    OpenLayers.loadURL(parcel, '', this, setHTML1);
                  }
                  else if ((mode == "mainhome") || (mode == "maingate") || (mode == "farmpts")) {
                    var gfi2 = "http://esri-arcims/wmsconnector/com.esri.wms.Esrimap?servicename=sansonr_fp_vw&version=1.1.1&request=GetFeatureInfo&QUERY_LAYERS=0&FEATURE_COUNT=10&INFO_FORMAT=text/plain&SRS=EPSG:2193&BBOX=" + bbox1 + "," + bbox2 + "," + bbox3 + "," + bbox4 + "&WIDTH=20&HEIGHT=20&X=10&Y=10";
                    OpenLayers.loadURL(gfi2, '', this, chkfarm);
                  }
                  var regc = "http://10.64.20.120/cgi-bin/gsswms.exe?service=WMS&version=1.1.1&request=GetFeatureInfo&LAYERS=regions&QUERY_LAYERS=regions&INFO_FORMAT=text/plain&SRS=EPSG:2193&BBOX=" + bbox1 + "," + bbox2 + "," + bbox3 + "," + bbox4 + "&WIDTH=20&HEIGHT=20&X=10&Y=10";
                  OpenLayers.loadURL(regc, '', this, setHTML2);
                  Event.stop(e);
                });
 
//Then we have a function setHTML1:
 
function setHTML1(response1) {
              var par = "";
              if(response1.responseText.length >= 1) {
                var lines = response1.responseText.split('\n');
                var pardat = lines[1].replace(/^"/,'').replace(/"$/,'').split('"  "');
                var parno = pardat[14];
                if (parno >= 1) {
                  dummyDate = new Date() ;
                  dummyParameter = dummyDate.getTime();
                  if(mode=="qry") {
                    var fdat = window.open('http://searchagribase.asurequality.com/agribasemapdata/indexpage.cfm?mode=qry&par=' + parno + '&dataset=complete',
                      "_blank","height=480,width=850,status=no,scrollbars=yes,toolbar=no,menubar=no,location=no");
                  }
                  else if(mode=="allocate"){
                    if(farmid>="A"){
                      falloc = 'http://searchagribase.asurequality.com/agribasemapdata/indexpage.cfm?mode=allocate&par=' + parno + '&farmid=' + farmid + '&dataset=farm';
                      OpenLayers.Util.getElement('ifrm').src = falloc;
                    }
                    else if(val>="0"){
                      valloc = 'http://searchagribase.asurequality.com/agribasemapdata/indexpage.cfm?mode=allocate&par=' + parno + '&val=' + val + '&dataset=val&time=' + dummyParameter;
                      OpenLayers.Util.getElement('ifrm').src = valloc;
                    }
                  }
                  else if(mode=="deallocate"){
                    if(farmid>="A"){
                      fdeall = 'http://searchagribase.asurequality.com/agribasemapdata/indexpage.cfm?mode=deallocate&par=' + parno + '&farmid=' + farmid + '&dataset=farm&time=' + dummyParameter;
                      OpenLayers.Util.getElement('ifrm').src = fdeall;
                    }
                    else if(val>="0"){
                      vdeall = 'http://searchagribase.asurequality.com/agribasemapdata/indexpage.cfm?mode=deallocate&par=' + parno + '&val=' + val + '&dataset=val&time=' + dummyParameter;
                      OpenLayers.Util.getElement('ifrm').src = vdeall;
                    }
                  }
                }
                else {
                  OpenLayers.Util.getElement('ifrm').src = "nothing.html";
                  alert("Nothing found!");
                }
              }
            }
 
//In the HTML section of our page we have an iframe specified which sits below the map div:
<div id="map" style="position:absolute;top:90px;left:2px;width:512px"></div>
<iframe id="ifrm" name="ifrm" scrolling="auto" style="position:absolute;top:620px;left:0px;width:512px;margin-left:0px;margin-top:0px" frameborder="0"></iframe>
 
regards,
 
Robert S
 

>>> maning sambale <emmanuel.sambale at gmail.com> 5/10/2009 10:22 p.m. >>>
Thanks! Any example openlayers page I can work on?
I know have a single html with anchors.  When a user clicks on the
link from the kml it should embed the html below the map going to the
anchored link.
------------------------------------------------------------------
The contents of this email are confidential to AsureQuality. If you have received this communication in error please notify the sender immediately and delete the message and any attachments. The opinions expressed in this email are not necessarily those of AsureQuality. This message has been scanned for known viruses before delivery. AsureQuality supports the Unsolicited Electronic Messages Act 2007. If you do not wish to receive similar communications in future, please notify the sender of this message.
------------------------------------------------------------------


This message has been scanned for malware by SurfControl plc. www.surfcontrol.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091006/9d0168e3/attachment.html


More information about the Users mailing list