Is there any way to fill a polyline?  
Author Message
Neilgd





PostPosted: Virtual Earth: Map Control Development, Is there any way to fill a polyline? Top

Does anybody have any ideas


Windows Live Developer Forums15  
 
 
cptscottie





PostPosted: Virtual Earth: Map Control Development, Is there any way to fill a polyline? Top

I'd like to know how to do this as well. Did you ever figure this out
 
 
Neilgd





PostPosted: Virtual Earth: Map Control Development, Is there any way to fill a polyline? Top

No I didn't. I took a different approach in the end.
 
 
Thomas Pyndt





PostPosted: Virtual Earth: Map Control Development, Is there any way to fill a polyline? Top

Hi

Which approach did you take

I am trying to create a map with coloured areas, but cannot find any information about this.

Thanks in advance.

Thomas


 
 
Neilgd





PostPosted: Virtual Earth: Map Control Development, Is there any way to fill a polyline? Top

I'm looking at two approaches.

Firstly, overlaying a png file over the map, and retrieving the graphic from a server. The advantage of this is that it's easier to write the drawing code on the server. A disadvantage is that it increases server load.

Secondly, I'm looking to draw the polygons using SVG/VML depending on the browser. There's an open source library that will do this (http://sourceforge.net/projects/excanvas). This means writing code in Javascript which isn't as easy.


 
 
Thomas Pyndt





PostPosted: Virtual Earth: Map Control Development, Is there any way to fill a polyline? Top

Hi again

It seems like it can be done using the VE API.

Take a look at this examble (the one with zip codes)

http://www.blogthevote.net/veshapefilec.htm

However, I can't figure out the sourcecode.


 
 
Neilgd





PostPosted: Virtual Earth: Map Control Development, Is there any way to fill a polyline? Top

Note how the mouse actions are disabled over the polygons though (ie you can't drag the map).

This seems to be using the commercial control. I'm not sure what this is, but I don't think it's the same as the Live one that I'm using.

Looking at the source code, if the browser is FireFox then it's using the inbuilt ability (via the canvas object) to draw shapes. If the browser is IE then it's using VML (by creating <v:shape/> tags) to make the polygons.

If you're going to use this approach then you'll be better off using the ExplorerCanvas API (see my previous post) for browser independence.


 
 
SpankmeBandit





PostPosted: Virtual Earth: Map Control Development, Is there any way to fill a polyline? Top

True you could use map cruncher to overlay the colors as tiles, think a really simple coloured map. Could be done simply in photoshop using layers then imported into map cruncher and match up the corners etc.
You would need to store the generated tiles on your webserver but then its more about serving images then processing complex polygon algorithms = it will scale.
Hope this helps. - If this works you should submit an article about it to viavirtualearth.
John.


 
 
SpankmeBandit





PostPosted: Virtual Earth: Map Control Development, Is there any way to fill a polyline? Top

Sorry this would only work if the data isn't going to change much. Like state mineral deposits or political boundaries. If your plotting something dynamic then this wouldn't work.
John.


 
 
m_armstrong





PostPosted: Virtual Earth: Map Control Development, Is there any way to fill a polyline? Top

The VE api uses vml or svg depending on the browser. Vector graphics can be drawn on type of the map using the ve api pixel function to determine points based on coordinates. This will allow you full control of how the graphics are drawn and shaded.
 
 
cptscottie





PostPosted: Virtual Earth: Map Control Development, Is there any way to fill a polyline? Top

Would you mind posting a code sample
 
 
sydneyausguy





PostPosted: Virtual Earth: Map Control Development, Is there any way to fill a polyline? Top

You have to make sure the points are in order. otherwise the polygon shape will morph, only works in IE.

result is an array of points

function MapTerritoryArea_callback(result)

{

var i = 0;

var locs = new Array();

var mylocs = result.Locations

var x = 0;

var y = 0;

for (i = 0;i <= mylocs.length - 1;i++) {

var ll = mylocsIdea;

var loc = new VELatLong(ll.Latitude, ll.Longitude);

locs.push(loc);

x = x + ll.Latitude;

y = y + ll.Longitude;

x = x / (i);

y = y / (i);

var loc = new VELatLong(x,y);

var col = result.Color;

var pol = new VEPolygon(result.Id, locs);

polygonID++;

pol.SetOutlineWidth(1);

pol.SetOutlineColor(new VEColor(result.Color.R,result.Color.G,result.Color.B,100));

pol.SetFillColor(new VEColor(result.Color.R,result.Color.G,result.Color.B,0.2));

try {

map.AddPolygon(pol);

}