[OpenLayers-Users] problems with a popup sans marker
Puneet Kishor
punk.kish at gmail.com
Mon Oct 17 18:06:43 EDT 2011
I am registering an click event to the map
map.events.register("click", map, popUp);
Then querying the db for the feature at the point of click
popUp: function(e) {
// From google to latlng
var lonlat = map.getLonLatFromViewPortPx(e.xy).transform(
proj.google,
proj.latlng
);
$.ajax({
url: "http://server/feature.json",
data: {lng: lonlat.lon, lat: lonlat.lat},
type: "GET",
dataType: "jsonp",
success: function(data) {
var html = unravel_data(data);
var c = map.getLonLatFromViewPortPx(e.xy);
map.addPopup(
new OpenLayers.Popup.Framed(
"featurePopup",
new OpenLayers.LonLat(c.lon, c.lat),
new OpenLayers.Size(200, 150),
html,
null,
false,
null
)
);
}
});
}
But, instead of the popup, I get the following in my console
OpenLayers.js: 2367: TypeError: 'null' is not an object (evaluating 'this.positionBlocks[this.relativePosition]')
Note that I want a popup without a marker or a vector feature. So, I have two questions --
1. How can I successfully draw the above popup?
2. Can I register the event to a layer instead of to the map? The reason is, this particular layer doesn't cover the entire map, so I want the feature query to be performed only when the user clicks on the layer.
--
Puneet Kishor
More information about the Users
mailing list