9

I'm having no luck finding examples. I've found code like that below but this is for earlier versions.

shapeLayer = new VEShapeLayer();
shapeSpec = new VEShapeSourceSpecification(VEDataType.ImportXML, layer.url, shapeLayer);
veMap.ImportShapeLayerData(shapeSpec);
2
  • I don't think this example represents kml. This looks like esri shapefile to my untrained eye. That said I am sure you could do a mashup between bing, and GE but read the license for restrictions.
    – Brad Nesom
    Aug 19, 2011 at 4:12
  • Nothing to do with ESRI shapefiles Brad. From the API doco - msdn.microsoft.com/en-us/library/bb412413.aspx VEShapeLayer Class Contains information about shape layers. Shape layers are a mechanism to create and manage arbitrary groups of shapes (pushpines, polylines, and polygons). Map shape layers can be created from GeoRSS XML files, custom map tiles, or from any public Bing Maps (maps.live.com) collection.
    – user2856
    Aug 19, 2011 at 5:10

6 Answers 6

4

Looks like the answer is no. I'm saying this based on looking at their SDK docs and this thread: Looking for KML or GeoRSS Example in Bing Maps Ajax Control v7.

If KML support is crucial, you could use Esri's ArcGIS API for JavaScript as it has support for publicly accessible KML layers. Full disclosure: I work at Esri on the JavaScript API team.

2
  • Curious: I find the ESRI license for JSAPI difficult to read. Can anyone use the jsapi to publish maps? For example could I use the JSAPI to display bing maps and not be in violation of any ESRI licenses? Same for google, OSM, ESRI Public Tiles? Or is it necessary for the user to be an ArcGIS Server user? OL is open but is JSAPI?
    – ca0v
    Feb 27, 2012 at 16:30
  • 1
    @user2023 We've been discussing JSAPI licensing internally and agree the story is not clear. We're working on improving this and plan to update several pages to reflect a simpler, easier to understand licensing story. Until we get the various pages updated, the story is this: use the JSAPI for internal, external, non-commercial and commercial sites/apps free of charge. You don't need to pay unless you start storing a large amount of data in arcgis.com and using the services (geometry, locator/geocoding and routing) on arcgis.com. Feb 27, 2012 at 18:26
2

As mentioned above, GeoRSS and KML are not supported. However, someone has written a GeoRSS interpreter for Bing Maps v7. And since KML files and GeoRSS files are both XML, so you can easily convert between the two using XSL. Some hunting shows that many people have talked about it, but I can't find any actual XSL file that does it. I did, however, find one the did the opposite, converting GeoRSS to KML, which should give you a good idea of where to start if you wrote your own.

If you only need to do this once, you could use to following two website to convert KML to GeoRSS via CSV:

  1. A KML to CSV converter using XSL.
  2. A CSV to GeoRSS webapp

And a final option is simply to write your own KML interpreter, in the same way someone wrote their own GeoRSS interpreter, per @Derek.

2
  • I'm confused...how is GeoRSS supported with the bing maps API? It's quite a stretch to say writing your own parsing code counts as "supported". Aug 19, 2011 at 17:27
  • Sorry, it isn't supported, but the post I linked to has an interpreter for using GeoRSS in Bing v7 with jQuery. I'll rewrite to be more clear.
    – Patrick
    Aug 19, 2011 at 17:34
2

Bing Maps 7.0 does not include a KML converter. But because it uses JavaScript objects to display data on the map (see Bing API), you can manually parse the kml and convert it to the respective objects.

In this code example, I use JavaScript to convert KML polygon data to new Microsoft.Maps.Polygon objects. I would then use the code below to add the polygons to my Bing map.

// Initialize the Map.
var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials:"Bing Maps Key"});

// Insert your own code to get your KML string here.

// Parse the kml into Microsoft.Maps.Polygon objects and add them to the map.
var polygons = bingKmlParser.parsePolygons(kmlString);
map.entities.push(polygons);
1
  • Does your KML have to be in a certain shape? Or would this work on any KML file?
    – J86
    Dec 20, 2016 at 8:32
1

Use Openlayers!! You can load KML files, and set Bing as your base map layer. And best of all, is open source, totally stable, and a very active project.

http://dev.openlayers.org/sandbox/rdewit/kml/examples/kml_wmsc_ows5.html

http://openlayers.org/dev/examples/bing.html

1
  • Not really an answer to the problem but a good workaround.
    – ca0v
    Aug 24, 2011 at 20:32
0

As most of the other posts have mentioned, it doesn't look like KML is directly supported in the Bing Maps Ajax control v7. However, I thought it is worth mentioning that it is supposedly supported in the normal maps GUI. In the following Bing blog post, it describes how one can import a KML into Bing Maps "My Places":

Not exactly what the question was looking for, but potentially useful for that kind of situation.

0

Try this kml parser for bing maps. example presented https://github.com/koldyr/BingKmlParser

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.