none
[SOLVED] What is the best way to display possibly hundreds of addresses without reloading or wasting user time RRS feed

  • Question

  • Hi,

    I have a bunch of addresses to display on a map. These addresses are pulled from a database. The user has the option to view addresses that were inputted between a certain date range, as well as view the establishments by type. I'm wondering what the most efficient way to make this website would be...

    Should I pull every address off the server in a huge XML file (addresses, establishment type, date built, other attributes as well) and simply work with that single file when determining what to display and what not to display, or would that be too clunky?

    I want a user to say, enter a start date, an end date, then change either one, and voila, on the spot the entries on the map are updated. No reloading of the page, little wait time. I just don't know the best direction I should go when doing this with Bing Maps.

    Thanks! I know this is more of a design question than a specific code question, but perhaps someone's got a tip for a newbie.

    Kevin

    • Edited by kevin-berry Sunday, June 12, 2011 10:49 PM
    • Moved by Ricky_Brundritt Friday, March 9, 2012 5:49 PM (From:Bing Maps: Map Control and Web services Development)
    Tuesday, May 31, 2011 1:31 AM

Answers

  • You can create a service returning json(array of locations) based on query, then display pushpins for array & call map.setview as below:

    var boundingBox = Microsoft.Maps.LocationRect.fromLocations(array of location);
    map.setView({ bounds: boundingBox});

     


    HemantGoyal
    Tuesday, May 31, 2011 1:41 AM
  • JSON is less verbose and you can get better performance by using JSON serialization.

    If you have already a database, you can easily get a JSON result out of it like you did for XML.


    MVP - Bing Maps - My blog (FR): http://blogs.developpeur.org/nicoboo/ Twitter: http://twitter.com/nicolasboonaert/
    Tuesday, May 31, 2011 8:59 AM
    Moderator
  • if you use asp .net web services the choice is made for you, it will return a JSON serialized array which you can deserealize using the javascript eval statement

     

    to make this more efficient, I would suggest considering several AJAX calls as the user pans and zooms in: find the viewing area, expand it by a factor (maybe twice the size) and query for that, it really depends on what your application is doing


    Sasha dos Santos Software Engineer Pro Tech Monitoring, Inc. http://www.ptm.com
    Tuesday, May 31, 2011 2:34 PM
  • take a look at the code sample here:

    http://bingmaps.codeplex.com/wikipage?title=Getting%20Started%20in%20Web%20Services&referringTitle=Home

    we wrote it to answer this kind of question by showing a real life example of how we recommend doing this in a fast and scalable way using javascript, wcf and json


    Brian @ Earthware - UK interactive mapping web developers http://www.earthware.co.uk/blog | http://www.twitter.com/earthware | Windows Live Developer MVP
    Tuesday, May 31, 2011 3:41 PM
    Moderator

All replies

  • You can create a service returning json(array of locations) based on query, then display pushpins for array & call map.setview as below:

    var boundingBox = Microsoft.Maps.LocationRect.fromLocations(array of location);
    map.setView({ bounds: boundingBox});

     


    HemantGoyal
    Tuesday, May 31, 2011 1:41 AM
  • Great! I'll have to read up on that solution more, but thanks for the heads up. So now the age-old question... JSON or XML? Should I consider re-coding to create a JSON feed rather than XML feed?
    Tuesday, May 31, 2011 1:47 AM
  • JSON is less verbose and you can get better performance by using JSON serialization.

    If you have already a database, you can easily get a JSON result out of it like you did for XML.


    MVP - Bing Maps - My blog (FR): http://blogs.developpeur.org/nicoboo/ Twitter: http://twitter.com/nicolasboonaert/
    Tuesday, May 31, 2011 8:59 AM
    Moderator
  • if you use asp .net web services the choice is made for you, it will return a JSON serialized array which you can deserealize using the javascript eval statement

     

    to make this more efficient, I would suggest considering several AJAX calls as the user pans and zooms in: find the viewing area, expand it by a factor (maybe twice the size) and query for that, it really depends on what your application is doing


    Sasha dos Santos Software Engineer Pro Tech Monitoring, Inc. http://www.ptm.com
    Tuesday, May 31, 2011 2:34 PM
  • take a look at the code sample here:

    http://bingmaps.codeplex.com/wikipage?title=Getting%20Started%20in%20Web%20Services&referringTitle=Home

    we wrote it to answer this kind of question by showing a real life example of how we recommend doing this in a fast and scalable way using javascript, wcf and json


    Brian @ Earthware - UK interactive mapping web developers http://www.earthware.co.uk/blog | http://www.twitter.com/earthware | Windows Live Developer MVP
    Tuesday, May 31, 2011 3:41 PM
    Moderator
  • Earthware, I'd love to try out that approach you suggested at codeplex - I've downloaded the zip, and taken a peruse through the files, but I have absolutely zero idea of how to even start seeing it in action and adapting it to my uses. In the WebApp, I tried opening the lone aspx file in Firefox, but it threw me an error saying it was not well-formed, as if it were XML or something. I would have sent this in a private message, but I'm not sure where that option is on these forums. Anyway, would you be able to point me in the right direction for getting started? Because I can't even find the documentation that explains that project/solution.

     

    Thanks!

     

    Kevin

    Thursday, June 2, 2011 8:43 AM
  • I presume you have not worked with asp.net before?

     

    you need to open the "project" in visual studio (try the express version its free) http://www.microsoft.com/express/Web/

     

    If you are brand new to asp.net, or web programming full stop this is not going to be simple for you to get running or adapt sorry


    Brian @ Earthware - UK interactive mapping web developers http://www.earthware.co.uk/blog | http://www.twitter.com/earthware | Windows Live Developer MVP
    Thursday, June 2, 2011 6:02 PM
    Moderator
  • EDIT: Seems to me that a "web service" could be as simple as an ajax call to PHP and returning some sort of response, like JSON. Once I solve my issues, I will post code in this thread detailing how I went about plotting points on a map using JQuery.
    Thursday, June 2, 2011 9:13 PM