[OpenLayers-Users] Looping through unique markers?

Heidt, Christopher M. CHRISTOPHER.M.HEIDT at saic.com
Mon Mar 2 09:09:08 EST 2009


That sounds like a resource problem.
Are you making sure that you are aren't trying to use openlayers
or any other js before its completely loaded?

-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
On Behalf Of David Raasch
Sent: Saturday, February 28, 2009 7:15 AM
To: users at openlayers.org
Subject: Re: [OpenLayers-Users] Looping through unique markers?

Odd....   The Firefox error console basically says nothing, whenever
Firefox
seems to be "trying forever" to open up this page / my script....and
Firebug
points to that line 224.    But if I open ANOTHER TAB and paste the
exact
same URL into it, the page / map loads and works just fine !!

Very strange.


-= Dave =-


-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
On Behalf Of David Raasch
Sent: Friday, February 27, 2009 3:21 PM
To: 'Heidt, Christopher M.'; users at openlayers.org
Subject: Re: [OpenLayers-Users] Looping through unique markers?

OK,  thanks to help from Chris....and studying the marker/event related
code over at openflights.org, I've managed to get my map to display in
Firefox, plus I've got my marker-specific pop-ups generating.

And yes, Firefox draws the points and zooms a heckuva lot faster!
So, the copy OUTSIDE of our corporate network is working the way I want
it to.

But when I try to pull up an identical copy saved to a webserver that's
WITHIN our corporate network, Firefox seems to be attempting to load the
page forever (white page). Firebug (which I really don't know how to
use) points to what is apparently line 224 in OpenLayers.js.

It does this whether I point this to the OpenLayers.js file over at the
OpenLayers site...or if I point it to a copy of that file as saved
within its own directory.


Line 224:
var factory=null;if(typeof GearsFactory!='undefined'){factory=new
GearsFactory();}else{try{factory=new
ActiveXObject('Gears.Factory');if(factory.getBuildInfo().indexOf('ie_mob
ile'
)!=-1){factory.privateSetGlobalObject(this);}}catch(e){if((typeof
navigator.mimeTypes!='undefined')&&navigator.mimeTypes["application/x-go
ogle
gears"]){factory=document.createElement("object");factory.style.display=
"non
e";factory.width=0;factory.height=0;factory.type="application/x-googlege
ars"
;document.documentElement.appendChild(factory);}}}


I don't suppose anybody might have a clue why this is doing this?



Thanks!

-= Dave =-






-----Original Message-----
From: Heidt, Christopher M. [mailto:CHRISTOPHER.M.HEIDT at saic.com]
Sent: Friday, February 27, 2009 12:22 PM
To: David Raasch; users at openlayers.org
Subject: RE: [OpenLayers-Users] Looping through unique markers?

 
Every browser cept ie7 is throwing "XMLHttpRequest.create is not
function"
-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
On Behalf Of David Raasch
Sent: Friday, February 27, 2009 12:35 PM
To: users at openlayers.org
Subject: Re: [OpenLayers-Users] Looping through unique markers?


 
OK, I discovered where apparently, this is known to happen when using
Vector layers.  And I had forgotten to comment-out my Vector layer
completely when switching over to using a Marker layer instead.  So,
I've got that part of it solved.

That leaves me with:

1) How to get each marker to have its own unique function? ( I know
right now it's just an "alert", but I plan on making that function
trigger a pop-up with some marker-specific HTML code in it in the near
future).
2) Why do none of the markers (or the circle, for that matter) display
in Firefox?

Thanks!

-= Dave =-


-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
On Behalf Of David Raasch
Sent: Friday, February 27, 2009 10:44 AM
To: users at openlayers.org
Subject: Re: [OpenLayers-Users] Looping through unique markers?

Hmmm... I just realized that if I go to the map controls and turn off
the circle and vector layers, then the events work for all icons, in the
sense that they all activate an "alert" pop-up.  Of course, the trouble
is, all alerts say exactly the same thing, basically showing the text
for point #571 only.

So, it looks like I've got two problems:  Why is it that the Vector and
Circle layers seem to be "interfering" with the click events?  And
apparently I have to figure out how to give each registered event
instance a reference to its own unique "evt" function.



-= Dave =-


-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
On Behalf Of David Raasch
Sent: Friday, February 27, 2009 8:13 AM
To: users at openlayers.org
Subject: [OpenLayers-Users] Looping through unique markers?


Greetings All!

When I posted to the list last week, I had coded my little app to use
FEATURES to draw marker icons and rig-up word-balloon pop-ups whenever
they were clicked-on.

However, the markers took a very, very long time to load.  So, digging
further into the archives of this discussion list, I discovered that,
although using MARKERS to draw marker icons is considered to be "the old
way of doing it", that way is apparently faster.

So, I set about commenting-out the feature-adding/drawing lines in my
code and inserting some lines that would loop through my array of data,
draw each marker, and register an event for that marker.

My problem is that I'm only getting the event to work on the FINAL
marker in the array.

I've posted my files here:

http://www.davidraasch.com/ww/map_v4.html


If you zoom in over that cluster near Chicago and click, eventually
you'll trigger an alert message on the one marker, which is the last one
in the array.  It will say "You clicked on marker m571".

Feel free to do a "view source", but here are the pertinent lines from
my
code:



var markers_layer = new OpenLayers.Layer.Markers( "Markers Layer");
map.addLayer(markers_layer);

	var xml_points =
xmlDoc.documentElement.getElementsByTagName("point");
		  		var m = [];
		  		for (var i = 0; i < xml_points.length;
i++) {
		         		var type =
xml_points[i].getAttribute("type");
		    	 	 	var thislat =
(parseFloat(xml_points[i].getAttribute("lat")));
	    		  		var thislng =
(parseFloat(xml_points[i].getAttribute("lng")));
	    		  		var html =
xml_points[i].getAttribute("html");

{to reduce "noise" here for you, I'm leaving out the if-then statements
that determine which exact icon graphic file to use, plus its height and
width }


	// Code to push each point as a MARKER LAYER MARKER
			  
					var size = new
OpenLayers.Size(icon_width,icon_height);
            			var offset = 0; // new
OpenLayers.Pixel(-(icon_width/2), -icon_height);
            			var icon = new
OpenLayers.Icon(icon_image,size,offset);
            			
   		   			
            			 m[i] = new OpenLayers.Marker((new
OpenLayers.LonLat(thislng,thislat).transform(new
OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())),icon);
            			 markers_layer.addMarker(m[i]);
   		  			 m[i].events.register ('click',
m[i], function(evt) {alert ('You clicked on marker m'+ i);
OpenLayers.Event.stop (evt); })

           				// alert("i="+ i);
				} // end of "for i = 0  to all POINTS
				



(Originally, I was using just the variable "m1" to represent the
markers, as taken from an example I found somewhere on the
openlayers.org site.  But then, in debugging it, I switched to using "m"
as an array, just to make sure I did understand what we're trying to do
here.)

I should also mention that, for some reason, the markers don't even
appear to load in Firefox!  I can only see them in IE.  ????

Any thoughts?


Thanks!

-= Dave =-



_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.237 / Virus Database: 270.11.3/1974 - Release Date:
02/26/09 14:51:00

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.237 / Virus Database: 270.11.3/1974 - Release Date:
02/26/09 14:51:00

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.237 / Virus Database: 270.11.3/1974 - Release Date:
02/26/09 14:51:00

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.237 / Virus Database: 270.11.3/1974 - Release Date:
02/26/09 14:51:00

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users



More information about the Users mailing list