none
Bing map - to custom read my shape file polygon for a particular zipcode - AJAX RRS feed

  • Question

  • Hello Experts, 

    I have developed a tool on bing map rendering shape files, with database connection and query being performed with certain selection which is fine, but this only gets displayed on the map, but some how it does not satisfy the needs, as our clients want to be able to click on the map on a particular shape which first of all highlights the selected polygon and then in-turn give me the data stored for that particular shape/polygon. Most importantly is this feature that I am looking for should give me a good interaction in such a way for eg. if I press ctrl and click on the shape of a particular region, that it should get added onto the rest of the highlighted shape which gives me the aggregate of say sales perhaps.

    Any Help !!!

    • Moved by Ricky_Brundritt Saturday, March 10, 2012 11:30 AM (From:Bing Maps: Map Control and Web services Development)
    Wednesday, October 5, 2011 12:32 PM

Answers

  • I'm finding it difficult to follow your description - you say that your source data is in ESRI shapefile format, but then also say that it's stored in an MSSQL database.... there's quite a difference between them.

    ESRI Shapefiles are designed to hold a set of data - they're not particularly good at retrieving individual elements from that set (it is possible, but you'll have to use some sort of shapefile parser to do so). Databases, in contrast, are very good at selecting and retrieving subsets of data from a set.

    To make Bing Maps "talk" to a mouse hover or click you need to add an event handler that listens for "mouseover" and "click" events on the map - http://msdn.microsoft.com/en-us/library/gg427623.aspx

    Then, in the MouseEventArgs element sent to the event callback method, you can retrieve the object that fired the event from the target property - http://msdn.microsoft.com/en-us/library/gg406731.aspx

    I'm assuming that every element in your shapefile/database has a unique ID, so retrieve the ID from the target object that was clicked on, and use this to run a query that returns all records that intersect the element with that ID, or whatever other query you wanted to run.


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Wednesday, October 5, 2011 2:51 PM
    Moderator
  • Heshti; There's a great book on these very issues; clicking on a shape and retrieving the data from MSSQL.  The book is Beginning Spatial with SQL Server 2008 (Apress) by tanoshimi.

    http://www.beginningspatial.com

    It really helped me understand this.

    Jay

    Wednesday, October 5, 2011 3:53 PM

All replies

  • Are you storing your data in SQL Server 2008/R2/Denali? If so, to select all those features from the database that intersect the chosen polygon, you can use a query such as:

    SELECT Data From DataTable WHERE geomcolumn.STIntersects(@SelectedPolygon) = 1;

    And, to join multiple polygons together that have been Ctrl+clicked, first create the union of those polygons:

    DECLARE @Union geometry = @Polygon1.STUnion(@Polygon2);

    Then select features as before, but based on those that intersect the combined union polygon.


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Wednesday, October 5, 2011 12:45 PM
    Moderator
  • Hello Tanoshimi, 

    the developed application is, shape file rendered onto the map, which is loaded with .shp, .shx, .dbf files

    and now I want to be able to access individual polygons on the map, the only things that are possible as I know of is 

    to javascript some lines of codes to pushpins or infoboxes etc, but there is no other possibility where I am able to access a particular polygon, how do I proceed.

    But yes I do have these polygon data stored in a MSSQL database , but I am using it outside the map for display of other related data.

    How do I make Bing map talk to my mouse hover or mouse click ?


    Heshti
    Wednesday, October 5, 2011 1:08 PM
  • I'm finding it difficult to follow your description - you say that your source data is in ESRI shapefile format, but then also say that it's stored in an MSSQL database.... there's quite a difference between them.

    ESRI Shapefiles are designed to hold a set of data - they're not particularly good at retrieving individual elements from that set (it is possible, but you'll have to use some sort of shapefile parser to do so). Databases, in contrast, are very good at selecting and retrieving subsets of data from a set.

    To make Bing Maps "talk" to a mouse hover or click you need to add an event handler that listens for "mouseover" and "click" events on the map - http://msdn.microsoft.com/en-us/library/gg427623.aspx

    Then, in the MouseEventArgs element sent to the event callback method, you can retrieve the object that fired the event from the target property - http://msdn.microsoft.com/en-us/library/gg406731.aspx

    I'm assuming that every element in your shapefile/database has a unique ID, so retrieve the ID from the target object that was clicked on, and use this to run a query that returns all records that intersect the element with that ID, or whatever other query you wanted to run.


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Wednesday, October 5, 2011 2:51 PM
    Moderator
  • Heshti; There's a great book on these very issues; clicking on a shape and retrieving the data from MSSQL.  The book is Beginning Spatial with SQL Server 2008 (Apress) by tanoshimi.

    http://www.beginningspatial.com

    It really helped me understand this.

    Jay

    Wednesday, October 5, 2011 3:53 PM
  • Hey,

    I am sorry if I confused you, but I get an idea what you mean.

    I see that its quite difficult to access the ESRI Shape file polygon, so I skiped the idea to do so , instead what I want to do is now, produce a push pin on all the locations that there queried from the database, but creating a dynamic GEO Rss  and then you can imagine that there are about 20 pishpins on the map.

    Now I need to be able to handle an event, perhaps through info box or jus a click on the pushpin which can inturn check certain checkboxes in the Gridview below so I can make further calculations.

    Can you guide me in this ??


    Heshti
    Monday, October 17, 2011 12:39 PM
  • Hey JayViz,

    Thanks for the link, I looked through it and I believe its very useful for me.

    thanks for the link again :)


    Heshti
    Monday, October 17, 2011 12:40 PM