Ok. I figured out the cause of the problem below, but I don't know the solution 
--

On Oct 17, 2011, at 5:06 PM, Puneet Kishor wrote:

> 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 --
> 


I believe, in order to have a Framed popup, I need to pass in an anchor which, 
per the docs, "must expose a ‘size’ OpenLayers.Size and ‘offset’ 
OpenLayers.Pixel (generally an OpenLayers.Icon)."

If I change the above to just `new OpenLayers.Popup()` then it works fine, but 
that is not what I want. How do I draw an Framed or FramedCloud popup without 
creating an icon? I simply want to click on a polygon and create a popup 
anchored to the point of click.


> 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

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to