Lonifasiko


Hi,

I'm using DrawPolygon method to draw lines in my map. In fact, I must draw in my map at least two "routes" (combination of lines). In the near future I'll surely need more routes.

Well, my first discovery: after loading a map with a specific zoom level, centered at a specific point, if I use DrawPolygon to draw a "virtual route" in my map, specified zoom level and center point are not taken into account. Please try the following example:

<html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"></script>
<script>var map = null;var pinID = 1;function GetMap(){map = new VEMap('myMap');
map.LoadMap(new VELatLong(41.02261619462957, -0.7516324999999847), 12,'h' , false, VEMapMode.Mode2D, false);
DrawPoly('f9d31f47-9762-4e39-91e0-0288c8a7fc03',[new VELatLong(40.405305, -3.68926),new VELatLong(40.3775438124365, -3.6820507049560547),new VELatLong(40.58632, -3.12640),new VELatLong(40.946701, -2.60801),new VELatLong(41.22023, -2.10355),new VELatLong(41.290705883574134, -1.8886184692382812),new VELatLong(41.3468967, -1.637303),new VELatLong(41.6587167, -0.9109967),new VELatLong(41.527016, -0.165585),new VELatLong(41.629814503758595, 0.5074310302734375),new VELatLong(41.6207633, 0.6336967),new VELatLong(41.55259061174702, 0.7480144500732422),new VELatLong(41.3760133, 1.16635167),new VELatLong(41.31598134210304, 1.185150146484375),new VELatLong(41.15903833, 1.09835833),new VELatLong(41.28947833, 1.25929167),new VELatLong(41.11084, 1.25246),new VELatLong(41.1833, 1.436),new VELatLong(41.18572167, 1.524275),new VELatLong(41.33063833, 2.08911833),new VELatLong(41.37471, 2.13483833333333),new VELatLong(41.3813167957953, 2.1749496459960937),new VELatLong(41.3838066666667, 2.185995)], 2, new VEColor(0,0,255,255));
}function AddPin(lat, long, imgPath, name, desc){var pin = new VEPushpin(pinID, new VELatLong(lat, long),imgPath, name, desc);map.AddPushpin(pin);pinID++;}function DrawPoly(id,points,width,color){poly = new VEPolyline(id,points);poly.SetWidth(width);poly.SetColor(color);map.AddPolyline(poly);map.SetMapView(points);}function GetCurrentZoomLevel(){if (map != null) return map.GetZoomLevel();else return null;}function GetMapCenter(){if (map != null) return map.GetCenter().toString();else return null;}function GetMapStyle(){if (map!=null) return map.GetMapStyle().toString();else return null;}</script></head>
<body onload="GetMap();"><div id='myMap' style="position:relative; width:665px; height:1218px;"></div></body></html>

As you can see, zoom level is very far from being 12! And map is not centered int the specified point! Well, as I needed to mantain the zoom level and the center point, I did it with this tricky way (bold and large text). Please do try again this code:

<html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"></script>
<script>var map = null;var pinID = 1;function GetMap(){map = new VEMap('myMap');
map.LoadMap(new VELatLong(41.02261619462957, -0.7516324999999847), 12,'h' , false, VEMapMode.Mode2D, false);
DrawPoly('f9d31f47-9762-4e39-91e0-0288c8a7fc03',[new VELatLong(40.405305, -3.68926),new VELatLong(40.3775438124365, -3.6820507049560547),new VELatLong(40.58632, -3.12640),new VELatLong(40.946701, -2.60801),new VELatLong(41.22023, -2.10355),new VELatLong(41.290705883574134, -1.8886184692382812),new VELatLong(41.3468967, -1.637303),new VELatLong(41.6587167, -0.9109967),new VELatLong(41.527016, -0.165585),new VELatLong(41.629814503758595, 0.5074310302734375),new VELatLong(41.6207633, 0.6336967),new VELatLong(41.55259061174702, 0.7480144500732422),new VELatLong(41.3760133, 1.16635167),new VELatLong(41.31598134210304, 1.185150146484375),new VELatLong(41.15903833, 1.09835833),new VELatLong(41.28947833, 1.25929167),new VELatLong(41.11084, 1.25246),new VELatLong(41.1833, 1.436),new VELatLong(41.18572167, 1.524275),new VELatLong(41.33063833, 2.08911833),new VELatLong(41.37471, 2.13483833333333),new VELatLong(41.3813167957953, 2.1749496459960937),new VELatLong(41.3838066666667, 2.185995)], 2, new VEColor(0,0,255,255));
map.SetZoomLevel(12);
map.SetCenter(new VELatLong(41.02261619462957, -0.7516324999999847));
}function AddPin(lat, long, imgPath, name, desc){var pin = new VEPushpin(pinID, new VELatLong(lat, long),imgPath, name, desc);map.AddPushpin(pin);pinID++;}function DrawPoly(id,points,width,color){poly = new VEPolyline(id,points);poly.SetWidth(width);poly.SetColor(color);map.AddPolyline(poly);map.SetMapView(points);}function GetCurrentZoomLevel(){if (map != null) return map.GetZoomLevel();else return null;}function GetMapCenter(){if (map != null) return map.GetCenter().toString();else return null;}function GetMapStyle(){if (map!=null) return map.GetMapStyle().toString();else return null;}</script></head>
<body onload="GetMap();"><div id='myMap' style="position:relative; width:665px; height:1218px;"></div></body></html>

This way, map loads the specified zoom level and is centered in the specified point. Ole!

However, now, I want to add the map another virtual route. I add another call to DrawPoly method in order to draw two points and.....my last frustration (you can also try):

Code Snippet
<html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"></script>
<script>var map = null;var pinID = 1;function GetMap(){map = new VEMap('myMap');
map.LoadMap(new VELatLong(41.02261619462957, -0.7516324999999847), 12,'h' , false, VEMapMode.Mode2D, false);
DrawPoly('f9d31f47-9762-4e39-91e0-0288c8a7fc03',[new VELatLong(40.405305, -3.68926),new VELatLong(40.3775438124365, -3.6820507049560547),new VELatLong(40.58632, -3.12640),new VELatLong(40.946701, -2.60801),new VELatLong(41.22023, -2.10355),new VELatLong(41.290705883574134, -1.8886184692382812),new VELatLong(41.3468967, -1.637303),new VELatLong(41.6587167, -0.9109967),new VELatLong(41.527016, -0.165585),new VELatLong(41.629814503758595, 0.5074310302734375),new VELatLong(41.6207633, 0.6336967),new VELatLong(41.55259061174702, 0.7480144500732422),new VELatLong(41.3760133, 1.16635167),new VELatLong(41.31598134210304, 1.185150146484375),new VELatLong(41.15903833, 1.09835833),new VELatLong(41.28947833, 1.25929167),new VELatLong(41.11084, 1.25246),new VELatLong(41.1833, 1.436),new VELatLong(41.18572167, 1.524275),new VELatLong(41.33063833, 2.08911833),new VELatLong(41.37471, 2.13483833333333),new VELatLong(41.3813167957953, 2.1749496459960937),new VELatLong(41.3838066666667, 2.185995)], 2, new VEColor(0,0,255,255));
DrawPoly('d4666d5e-3baa-447c-94bd-a92c47259087',[new VELatLong(40.405305, -3.68926),new VELatLong(37.38107035775657, -5.9820556640625)], 2, new VEColor(255,255,0,255));
map.SetZoomLevel(12);
map.SetCenter(new VELatLong(41.02261619462957, -0.7516324999999847));
}function AddPin(lat, long, imgPath, name, desc){var pin = new VEPushpin(pinID, new VELatLong(lat, long),imgPath, name, desc);map.AddPushpin(pin);pinID++;}function DrawPoly(id,points,width,color){poly = new VEPolyline(id,points);poly.SetWidth(width);poly.SetColor(color);map.AddPolyline(poly);map.SetMapView(points);}function GetCurrentZoomLevel(){if (map != null) return map.GetZoomLevel();else return null;}function GetMapCenter(){if (map != null) return map.GetCenter().toString();else return null;}function GetMapStyle(){if (map!=null) return map.GetMapStyle().toString();else return null;}</script></head>
<body onload="GetMap();"><div id='myMap' style="position:relative; width:665px; height:1218px;"></div></body></html>

Well, summing up, my problem is although two routes are correctly shown, zoom level and map center point are not taken into account when using DrawPolygon.

Is this a known issue Maybe is it a bug I would really appreciate any help on this. Sure somebody has see it before!

Thanks very much in advance.

PS: Could not add three code samples as code snippets. Thi editor only seems to allow one per thread.




Re: Zoom level and map center point not taken into account when using DrawPolygon

CIAndrew


Hey Miguel,

There does indeed seem to be a problem. I got it to work if you change the map div to:

Code Snippet
<div id="myMap" style="position:relative; width:100%; height:100%"></div>

Not sure why it makes a difference though....

Regards,

Andrew






Re: Zoom level and map center point not taken into account when using DrawPolygon

Lonifasiko

Hi Andrew,

Thanks for your time. I thought anybody was going to take a look at my examples :-)

I've tried changing the width and height of the div (as you said), and yes, the shown map is different, but still don't see it well centered, at the given point. At least, it is different!

It definitively sounds like a bug. I hope VE team takes a look at it.

Regards.