Its easy :-)

 

This is the soloution

 

map.zoomToExtent(markers.getDataExtent());

 

K-

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Kenny
Sent: 18 September 2008 03:42 PM
To: [email protected]
Subject: [OpenLayers-Users] getDataExtent
Importance: High

 

Hi All,

 

I have the following function that retrieve info from a xml file and
displays the markers

 

What I am trying to do is zoom to the position where the markers are

I think I should be using the getDataExtent() function but unfortunately I
don’t really know how to to.

 

Could someone Please give me a tip?

 

Thanks

 

K-

 

 

 

 

 function loadSuccess(request) {

            

         doc = request.responseXML;

          

         var x_markers = doc.getElementsByTagName("marker");

                         

                         for (i=0; i<x_markers.length; i++){

                            var id =
x_markers[i].getElementsByTagName("id")[0].firstChild.nodeValue;

                                    var imei =
x_markers[i].getElementsByTagName("imei")[0].firstChild.nodeValue;

                                    var lat =
x_markers[i].getElementsByTagName("lat")[0].firstChild.nodeValue;

                                    var lng =
x_markers[i].getElementsByTagName("lng")[0].firstChild.nodeValue;

                                    var time =
x_markers[i].getElementsByTagName("time")[0].firstChild.nodeValue;

                                    var speed =
x_markers[i].getElementsByTagName("speed")[0].firstChild.nodeValue;

                                    var icon =
x_markers[i].getElementsByTagName("icon")[0].firstChild.nodeValue;

                                    var addpoly =
x_markers[i].getElementsByTagName("addpoly")[0].firstChild.nodeValue;

                                    //add the markers

                                            addMarkers(lat,lng,'../icons/'+
icon +'.gif',id); 

                                     //polys

                                     if (addpoly == 1){

                                                  newPoint = new
OpenLayers.Geometry.Point(lng,lat);

                                                   pointList.push(newPoint);

                                                   lineFeature = new
OpenLayers.Feature.Vector( new
OpenLayers.Geometry.LineString(pointList),null,poly_style);

                                                   lineFeature.fid = 52751;

 
polys.addFeatures([lineFeature]);

                                                             

                                   } //end Polys

 

               }

        }

 

  _____  

I am using the free version of SPAMfighter for home users.
SPAMfighter has removed 583 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter <http://www.spamfighter.com/len>  for free now!


  _____  

I am using the free version of SPAMfighter for home users.
SPAMfighter has removed 676 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter <http://www.spamfighter.com/len>  for free now!

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

Reply via email to