none
Bing map web services - issue with importing kml file

    Question

  • I am a new bie and started developing an application using Bing map web services. I am trying to import  kml file to a bing map to show our service territory on a bing map. I am getting a message saying that 0 items loaded. Any ideas of what might be the issue. I tired the same with gml file and I sitll didnot have luck. I copied the kml file on my development server.

    Here is a code snippet.

    function

     

    pageLoad()

    {

    map =

    new VEMap('myMap');

    map.LoadMap(

    new VELatLong(36.4478, -74.5637), 10);

     

     

    var layer = new VEShapeLayer();

     

    var veLayerSpec = new VEShapeSourceSpecification(VEDataType.ImportXML, "http://<url name>/<folder name>/xxx.kml", layer);

    map.ImportShapeLayerData(veLayerSpec,onFeedLoad);

     

     

    }

     

     

    function onFeedLoad(feed)

    {

    alert(

    'RSS or Collection loaded. There are ' + feed.GetShapeCount() + ' items in this list.');

    }

    Wednesday, July 15, 2009 2:40 PM

Answers

  • Thanks for everyone. I was able to resolve the issue. Due to some reason, my Safe FME doesn't have an option to convert the shapefile to GeoRss directly. I converted shape file to KML using safe FME and used some C# code( I found this on the internet) to convert KML to GeoRSS. That works great.
    Thursday, August 06, 2009 6:38 PM

All replies

  • You should probably copy and paste a copy of the kml file to verify the format is correct. To check the format of the kml file and make sure that isn't an issue, try using a tool like: http://kml-samples.googlecode.com/svn/trunk/interactive/index.html
    Wednesday, July 15, 2009 4:03 PM
  •  I tried the tool. It didnot return any parser error. It just seems like it was hung up loading the google earth when I clicked on "Update Earth" after pasting my kml. I want to mention that my kml file is 339 kb with about 9K coordinates. I am not sure if that could be an issue.


    Wednesday, July 15, 2009 5:55 PM
  • Another way to make sure the kml is valid and not the problem is importing it in Google Earth (desktop version) from your local hard drive.
    Wednesday, July 15, 2009 6:09 PM
  • Sorry. It took a while to get back. I have been having issues with my computer and got stuck with fixing them. Anyway, I tried to import it on bing.com  and that works too. But, when I host it on my local IIS and access it, it doesn't work. http://blog.reevestech.net/ This article says that in order for KML overlays work in Bing Maps, the KML file has to be on an internet-accessible machine. Is that the only way available? We are behind the firewalls and I am not sure if Corporate policies let us do that.

    Besides, kml files approach, whatelse can I do to import layers on a map. I read little bit about collections and gml. From what I understood from collections, it looks like we will be depending on Bing map server to store the data and we access it through collections. Is that right? So, what if that server is down for some reason, then our internet users will not be able to get the layers on the map - Correct?

    I tried to use gml file - but, I am nto sure if I am doing it right. I hosted gml file on local host and here is the code I used to access the file with no luck. 
    var veLayerSpec  =  new VEShapeSourceSpecification(VEDataType.ImportXML, "http://<url name>/<folder name>/xxx.gml", layer);

    Any ideas or direction is appreciated.

    Thanks.
    Friday, July 17, 2009 5:39 PM
  • Yes - when importing from kml, the location on which the KML file resides must be on a publicly accessible server, since the file must be retrieved and sent to Bing servers for processing before being returned to the client.
    However, you can create shapelayers from GeoRSS hosted on local machines, which is format that implements (a subset of) GML, and implements most of the same features as KML.
    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Friday, July 17, 2009 6:27 PM
    Moderator
  • Thanks for the information. So, I assume that the shapelayers that are created from GeoRSS would be in an XML format. Correct?

    Meanwhile, I went ahead, uploaded my kml file on bing.com and took the collection ID and stuck it in my code and I was able to plot the service terriotry. I am not sure if that is a recommended approach than creating shapelayers from GeoRSS and host it from a local machine(or local servers). What are Pros and cons between using one method over the other?
    Friday, July 17, 2009 7:36 PM
  • You can also try the KML Validator at http://www.kmlvalidator.com .  This checks the syntax of your KML against the OGC KML 2.2 specification.  Remember that BING does not support all of KML.
    Saturday, July 25, 2009 8:08 PM
  • GeoRSS is XML, correct.

    Essentially, it's the same as regular RSS, except with embedded geometry as shown in the examples below:

    GeoRSS-Simple

    <georss:point>45.256 -71.92</georss:point>

    GeoRSS-GML

      <georss:where>
        <gml:Point>
          <gml:pos>45.256 -71.92</gml:pos>
         </gml:Point>
      </georss:where>
    Additional info on GeoRSS can be found here:  http://georss.org/Main_Page

    Tuesday, July 28, 2009 3:58 PM
  • Thanks David. We have a different team that generates Shape files. They use FME to generate the Shape files and convert them to Kml. But, since it is not feasible for us to put those files outside the firewall to show them on a bing map, I started looking into using GML.  However, they are not sure how they can generate these gml files from the ESRI shape files? I appreciate if you can shed some light into this?

    Thanks.
    Thursday, July 30, 2009 6:13 PM
  • If you've already got access to Safe FME then you can use that to convert from shapefile to GeoRSS directly...
    http://www.safe.com/solutions/application/esri/formats-supported.php

    (Note that Bing maps doesn't support GML, but rather georss (which can contain GML))
    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Thursday, July 30, 2009 6:21 PM
    Moderator
  • Thanks for everyone. I was able to resolve the issue. Due to some reason, my Safe FME doesn't have an option to convert the shapefile to GeoRss directly. I converted shape file to KML using safe FME and used some C# code( I found this on the internet) to convert KML to GeoRSS. That works great.
    Thursday, August 06, 2009 6:38 PM
  • Hi,

    Could you please let me know how did you do it?

    I have a KML file and I need to populate the Bing Map with it

    Thanks in advance.

     

    Mayank

    Tuesday, May 10, 2011 12:35 PM