<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hello Andreas,<br>
<br>
Thanks for your help - I will look into it. I thought the Sundials
example was too tied to KML files, so this is why I didn't chose to
follow it. <br>
<br>
I will continue this thread if I run into unsolvable problems.<br>
<br>
Regards,<br>
Adrian<br>
<br>
Andreas Hocevar wrote:
<blockquote
 cite="mid:5b021dd0906211128n3777e1e8yf8cd90be2c112f56@mail.gmail.com"
 type="cite">
  <pre wrap="">Hi,

On Fri, Jun 19, 2009 at 3:00 PM, Adrian
Popa<a class="moz-txt-link-rfc2396E" href="mailto:adrian_gh.popa@romtelecom.ro">&lt;adrian_gh.popa@romtelecom.ro&gt;</a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Here's what I'm trying to do (let me know if I'm reinventing the wheel):
I want to load a bunch of markers onto an existing map, and I want to
register a function to react to a click event. The function will create
a popup and get some content through an ajax call to display on the map.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Please consider using a vector layer instead of a markers layer for
your markers. Then, you add a SelectFeature control to the map,
configured with your vector layer. Now all you have to do is create
your popup in a listener for the layer's featureselected event.

As a starting point, have a look at the sundials example
(<a class="moz-txt-link-freetext" href="http://www.openlayers.org/dev/examples/sundials.html">http://www.openlayers.org/dev/examples/sundials.html</a>). Create your
vector layer without the protocol and strategies options. You can add
your markers (called features for a vector layer) to the layer anytime
by saying:

var feature = new OpenLayers.Feature.Vector(
    new OpenLayers.Geometry.Point(lon, lat), {
        myAttribute1: "foo",
        myAttribute2: "bar"
    }, {
        externalGraphic: "yourMarkerImageURL"
    }
);
map.addFeatures([feature]);

For creating the popup content (see onFeatureSelect function in the
sundials example), you can e.g. access the myAttribute1 property by
evt.feature.attributes.myAttribute1.

  </pre>
  <blockquote type="cite">
    <pre wrap="">I went through a lot of examples on the net, but things got complicated
- because they started using jugl.js (don't know what that is), or
displaying KML content.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Jugl is a cool template system, created by Tim Schaub. And using
vector layers, it makes no difference whether you display KML content
or features that you add to your layer programmatically.

  </pre>
  <blockquote type="cite">
    <pre wrap="">Can you point me to an example of a popup that gets its contents through
a definable function?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
See above, I think that should get you there.

Regards,
Andreas.

  </pre>
</blockquote>
<pre class="moz-signature" cols="72">
</pre>
</body>
</html>