Hi Derek,
Thank you for the quick response.
When I load the page I initialize the map centered on Romania. When I click
the button to load the Polyline, everything works correctly but, as I said
the Polyline loads in the wrong place.
I attached 3 pictures:
map1.jpg - how my map looks when I load the page
map2.jpg - a huge zoom out, with the location where the Polyline is placed
map3.jpg - a zoom in on the Polyline
I include in my page 2 external scripts:
*<script
src="http://openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript" charset="utf-8" src="
http://mapstraction.googlecode.com/svn/trunk/source/mxn.js?(openlayers)
"></script>
*
I initialize the map with this function:
*function initialize()
{
// function taken from Mapstraction Sandbox
// initialise the map with your choice of API
gmapstraction = new
mxn.Mapstraction(''harta'',''openlayers'');
// create a lat/lon object
// this point is in the middle of the country
var myP = new mxn.LatLonPoint(45.6362048,25.6338112);
// display the map centered on a latitude and longitude (Google zoom
levels)
gmapstraction.setCenterAndZoom(myP, 8);
gmapstraction.addControls({
pan: true,
zoom: ''large''
});
}*
And when a button in clicked I load the Polyline:
*function puneTraseu(xmlresp)
{
// this function has to display a polyline with points from an XML -
bellow I put a sample of the xml file;
var puncte = xmlresp.getElementsByTagName(''punct'');
var i;
var longi;
var lat;
var point;
var points = [];
for (i=0; i<puncte.length ; i++)
{
lat
puncte[i].getElementsByTagName(''lat'')[0].childNodes[0].nodeValue
;
longi
puncte[i].getElementsByTagName(''long'')[0].childNodes[0].nodeValue
;
point = new mxn.LatLonPoint(lat, longi);
points.push(point);
}
var myPoly = new mxn.Polyline(points);
myPoly.setColor("#FF0000");
gmapstraction.addPolyline(myPoly);
alert(''READY!'');
}*
A xml example with the points of the polyline I display is also attached -
the xml attached give the polyline in map3.xml.
I tried to use "toOpenLayers" object, because from what I managed to
understand it is probably a projection problem, but with no luck.
I would greatly appreciate any idea or suggestion.
Thank you,
Radu.
On Thu, Mar 4, 2010 at 10:59 AM, Derek Fowler <dezfowler at gmail.com>
wrote:
> Hi Radu,
>
> Sounds like you may just need to center your map. I''d set the
center to
> somewhere in Romania before you start and then use autoCenterAndZoom after
> you draw your polyline.
>
> I''d you''re already doing that then post your code and
we''ll see if we can
> help. You may have just found a bug in the library.
>
> Derek
>
> On Mar 3, 2010 11:30 PM, "Raducu MARDALE" <radu.mardale at
gmail.com> wrote:
>
> Hello everyone,
>
> If by writing to everyone I am doing something wrong please excuse me and
> just ignore this mail.
>
> I''m trying to put together a web site in which I can track my car.
I have
> the coordinates of my car and I am trying to use mapstraction to view the
> tracks on an OpenLayers Map.
>
> Everything works fine, except the Polyline I am drawing has the right
> shape, put it''s placed somewhere over the water, South of Africa -
I am from
> Romania, so something is not right.
>
> I read the Api Documentation and I can''t figure out what to do. I
tried the
> Mapstraction Sandbox, and if I paste my Polyline there it is places
> correctly - this really got me locked.
>
> Please tell me where else to look, or if anyone got the same problem please
> let me know. If the code would help, let me know.
>
> Thank you.
>
> --
> Radu Mardale
> -----------------------------
> radu.mardale at gmail.com
> 004 (0) 744 347 378
>
> _______________________________________________
> Mapstraction mailing list
> Mapstraction at lists.mapstraction.com
> http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com
>
>
--
Radu Mardale
-----------------------------
radu.mardale at gmail.com
004 (0) 744 347 378
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100304/e2ae2a6a/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: traseu.xml
Type: text/xml
Size: 41254 bytes
Desc: not available
URL:
<http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100304/e2ae2a6a/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: map1.jpg
Type: image/jpeg
Size: 104718 bytes
Desc: not available
URL:
<http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100304/e2ae2a6a/attachment-0003.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: map2.jpg
Type: image/jpeg
Size: 106016 bytes
Desc: not available
URL:
<http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100304/e2ae2a6a/attachment-0004.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: map3.jpg
Type: image/jpeg
Size: 61350 bytes
Desc: not available
URL:
<http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100304/e2ae2a6a/attachment-0005.jpg>