[OpenLayers-Users] Return Popup Map Click latlon Values to
ParentPage
Obe, Regina
robe.dnd at cityofboston.gov
Tue Apr 3 12:27:30 EDT 2007
Not sure why you are doing innerHTML - those are usually used to fill
span and div elements.
If its a text box, I would think you should be using
txtLat.value =
Also if they are runat server controls - you should verify that the id
is really txtLatitude by looking at the generated view source. If the
control is within a master page or another container element, then part
of the rendered html id is the containing elements id and not just the
control's aspx id.
________________________________
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
On Behalf Of Brian Krebs
Sent: Tuesday, April 03, 2007 12:19 PM
To: users at openlayers.org
Subject: [OpenLayers-Users] Return Popup Map Click latlon Values to
ParentPage
I'm working with C# and ASP.Net and am wondering if anyone else has had
to figure out the following scenario:
I'm opening up the map in a popup page using the following code from a
linkbutton click.
protected void lbMap_Click(object sender, EventArgs e)
{
lblMapWarning.Visible = false;
if (txtLocateCity.Text.Trim() == "")
{
lblMapWarning.Visible = true;
return;
}
string street = txtHouseNumber.Text + " " + ddStreetPrefix.Text
+ " " + txtStreetName.Text + " " + ddStreetType.Text + " ";
street += ddStreetSuffix.Text;
string city = txtLocateCity.Text;
string stateCode = "OK";
//string zipCode = txtZipCode.Text;
GeoAddress address = geoAPI.GeoEncodeAddress(street.Trim(),
city.Trim(), stateCode);
string sLat = address.Latitude;
string sLon = address.Longitude;
string sZoom = address.Precision;
if (address.Precision == "address")
sZoom = "8";
else
sZoom = "7";
string page = "Mapping/MapServer.aspx?lat=" + sLat + "&lon=" +
sLon + "&zoom=" + sZoom;
string scriptString = buildMapPopupScript(page);
if (!Page.IsStartupScriptRegistered("Startup"))
Page.RegisterStartupScript("Startup", scriptString);
}
static public string buildMapPopupScript(string url)
{
return buildPopupScript(url, 200, 200, 40, 20, 675, 900);
}
static public string buildPopupScript(string url,
int screenX, int screenY, int left, int top, int height, int
width)
{
string s = "";
s += "<script language=javascript>\n";
s += "window.open('" + url + "',";
s += "'_blank',";
s += "'menubar=no,";
s += "resizable=yes,";
s += "location=no,";
s += "directories=no,";
s += "status=yes,";
s += "copyhistory=no,";
s += "screenX=" + Convert.ToString(screenX) + ",";
s += "screenY=" + Convert.ToString(screenY) + ",";
s += "left=" + Convert.ToString(left) + ",";
s += "top=" + Convert.ToString(top) + ",";
s += "scrollbars=yes,";
s += "toolbar=yes,";
s += "height=" + Convert.ToString(height) + ",";
s += "width=" + Convert.ToString(width) + "');\n";
s += "</script>";
return s;
}
I'm registering a click event in the MappingFuncs.js with this code to
try to return the lat/lon values back to the parent page:
openLayersMap.events.register("click", openLayersMap, function(e)
{
var lonlat = openLayersMap.getLonLatFromViewPortPx(e.xy);
var markersLayer = new OpenLayers.Layer.Markers("Locate");
var marker = new OpenLayers.Marker(new
OpenLayers.LonLat(lonlat.lon, lonlat.lat), new
OpenLayers.Icon("http://openlayers.org/api/img/marker.png", new
OpenLayers.Size(15,25)));
alert("You clicked " + lonlat.lon + ", " + lonlat.lat);
markersLayer.addMarker(marker);
openLayersMap.addLayer(markersLayer);
// var txtLat =
window.opener.window.document.getElementById("txtLatitude");
// txtLat.innerHTML = lonlat.lat;
// var txtLon =
window.opener.window.document.getElementById("txtLongitude");
// txtLon.innerHTML = lonlat.lon;
});
I found the commented code on www.asp.net <http://www.asp.net/> to use
window.opener, but my vars txtLat and txtLon are always coming back as
null. Does anyone know a good way to return the lonlat values back to
my textboxes in the parent page?
Thanks
-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
More information about the Users
mailing list