Atlas Demo Application and help with PushPins

Last post 11-08-2005 3:29 PM by WilcoB. 12 replies.

Sort Posts:

  • Atlas Demo Application and help with PushPins

    10-05-2005, 4:25 PM
    • Loading...
    • dwahlin
    • Joined on 06-14-2002, 7:09 PM
    • Arizona
    • Posts 18
    • ASPInsiders
      TrustedFriends-MVPs
    I put together a little Atlas demo application that shows how Northwind customer data can be easily displayed with autocomplete help and Virtual Earth map integration.  As a particular customer or group of customers is selected by country the Virtual Earth map will pan to the country.  A nice visual effect especially given that I only had to write around 3-4 lines of JavaScript (not including the Web Service code that locates Longitude and Latitude of course).  The code for the app can be found here:

    http://www.xmlforasp.net/CodeSection.aspx?csID=116

    While I'm pretty happy with the app overall, I couldn't find a way to dynamically add pushpins to the map using JavaScript.  I looked into the appropriate Virtual Earth Javascript file supplied with Atlas and don't see a method like addPushpin() (although I do see _addPushpin()).  Anyone know how to handle dynamic pushpins?  I'm guessing that there's a way and I just didn't try it yet.

    Dan
  • Smile [:)] Re: Atlas Demo Application and help with PushPins

    10-06-2005, 2:16 PM
    • Loading...
    • Dr.NETjes
    • Joined on 02-13-2004, 2:39 PM
    • Posts 71

    Very nice demo, Dan! Thanks for that!
    This is the first downloadable Atlas demo that really works.

    Some notes:
    - be sure to set your regional settings to English (US), because Atlas returns errors on regional settings that use a comma as decimal symbol (like Dutch).
    - I changed the code for the GetCountries webservices a bit, so it really uses the 'prefixText' parameter.

  • Re: Atlas Demo Application and help with PushPins

    10-06-2005, 2:40 PM
    • Loading...
    • WilcoB
    • Joined on 03-02-2003, 8:02 AM
    • Posts 288
    The map supports 2 kind of pushpins: databound and non-databound. In that matter, it is pretty close to the ListBox control in ASP.NET 2.0: You can add items "statically", and you can still databind it and the dataitems can be appended (so it doesn't replace your statically added items). This is what the map can do as well.

    You can databind the map like you can databind the listview. The map has properties like DataLatitudeField and DataLongitudeField (which default to "Latitude" and "Longitude" respectively). This means you could add  an atlas DataSource control to your page and add a binding between this datasource and the map. The code could look like this:

    <atlas:DataSource id="customerData" runat="server" serviceURL="Customers.asmx" />

    <atlas:VirtualEarthMap Runat='server" ....>
      <Bindings>
        <atlas:Binding DataContext="customerData" DataPath="data" Property="data" />
      </Bindings>
    </atlas:VirtualEarthMap>

    Your webservice should return something IEnumerable, where each "row" has a property "Latitude" and "Longitude".

    Additionally, you can statically add pushpins too:

    <atlas:VirtualEarthMap Runat="server" ...>
      <Pushpins>
        <atlas:Pushpin Latitude="..." Longitude="..." PushpinImageUrl="..." />
      </Pushpins>
    </atlas:VirtualEarthMap>

    Please note that static pushpins can have bindings too (which you can use to bind data to this pushpin, which can be used in the popup):
    <atlas:VirtualEarthMap Runat="server" ...>
      <Pushpins>
        <atlas:Pushpin Latitude="..." Longitude="..." PushpinImageUrl="...">
          <Bindings>
            <atlas:Binding DataContext="someContext" Property="data" />
          </Bindings>
        </atlas:Pushpin>
      </Pushpins>
      <Popup>
        <atlas:Label Runat="server">
          <Bindings>
            <atlas:Binding DataPath="CustomerName" Property="text" />
          </Bindings>
        </atlas:Label>
      </Popup>
    </atlas:VirtualEarthMap>

    If you want to programmatically add pushpins, you should create a Pushpin object and add that to the pushpins property of the map, like so:

    var myPushpin = new Web.UI.Pushpin();
    myPushpin......
    var pushpins = myMap.get_pushpins();
    pushpins.add(myPushpin); <- when we add the pushpin to the map, the pushpin will be parented to (and know about) the map
    myPushpin.initialize(); <- We need to initialize _after_ adding it to the map. This initialize function takes care of actually adding the pushpin to the map (visually).

    Please let me know if you have any questions, or can't get this working. I could help you to get you up to speed.

    Update: by the way, this is a cool example that you have made. You could even do it all declaratively :). For example, you could return customer data (with latitude/longitude), and bind that to a ListView AND the map. Additionally, you could add a "navigate to" button to the listview, and add an action to the button which invokes the "panTo" method on the map. You could then click on this button and the map will center the pushpin of that customer :).
    - Wilco Bauwer (MSFT) / http://www.wilcob.com
  • Re: Atlas Demo Application and help with PushPins

    10-06-2005, 5:59 PM
    • Loading...
    • WilcoB
    • Joined on 03-02-2003, 8:02 AM
    • Posts 288
    I have created a slightly different version of your idea. Go to http://www.wilcob.com/Wilco/Default/158/showpost.aspx for explanation and results.
    - Wilco Bauwer (MSFT) / http://www.wilcob.com
  • Re: Atlas Demo Application and help with PushPins

    10-06-2005, 6:33 PM
    • Loading...
    • dwahlin
    • Joined on 06-14-2002, 7:09 PM
    • Arizona
    • Posts 18
    • ASPInsiders
      TrustedFriends-MVPs
    Good stuff Wilco...and thanks for sharing your pushpin idea.  I'll give that a shot.  I updated my blog with a reference to yours so people could get a look at doing things in a more declarative manner. 

    http://weblogs.asp.net/dwahlin/archive/2005/10/06/426833.aspx

    Dan
  • Re: Atlas Demo Application and help with PushPins

    10-06-2005, 7:06 PM
    • Loading...
    • WilcoB
    • Joined on 03-02-2003, 8:02 AM
    • Posts 288
    Thanks for the plug.

    Please make sure that if you run into any issues with the map, that you try my modified version of AtlasUIMap.js which fixes some bugs in the current Atlas release.
    - Wilco Bauwer (MSFT) / http://www.wilcob.com
  • Re: Atlas Demo Application and help with PushPins

    10-10-2005, 3:22 AM
    • Loading...
    • andersmunk
    • Joined on 10-10-2005, 7:15 AM
    • Copenhagen, Denmark
    • Posts 2

    I have tried to setup the Atlas demo application but I get a Javascript error which I have tracked down to be related to commas in float values. I guess that is what you mean in your post related to regional settings..

    Now my questtion goes: How do I change the regional settings? Web.config? or in the code?

    Regards
    Anders

  • Re: Atlas Demo Application and help with PushPins

    10-10-2005, 9:27 AM
    • Loading...
    • WilcoB
    • Joined on 03-02-2003, 8:02 AM
    • Posts 288
    Try adding the globalization tag to your web.config, and set both the uiCulture and culture attributes.

    - Wilco Bauwer (MSFT) / http://www.wilcob.com
  • Sv.: Re: Atlas Demo Application and help with PushPins

    10-10-2005, 3:38 PM
    • Loading...
    • andersmunk
    • Joined on 10-10-2005, 7:15 AM
    • Copenhagen, Denmark
    • Posts 2

    Thanks. Just what I needed.

    /Anders

  • Re: Atlas Demo Application and help with PushPins

    10-20-2005, 2:04 PM
    • Loading...
    • Dr.NETjes
    • Joined on 02-13-2004, 2:39 PM
    • Posts 71
    Hi Dan,

    Notice that your demo isn't working all the way in FireFox. Problem is that you use a javascript var named 'long', which is a reserved word in FireFox (and should also be in IE :)

    --Dion
  • Re: Atlas Demo Application and help with PushPins

    11-06-2005, 5:44 PM
    • Loading...
    • pauley
    • Joined on 08-24-2005, 2:36 AM
    • Posts 38

    Hey Dan, Your sample using virtual earth is great BUT  I cannot get it to work.  I am using Visual Web Developer (VWD) 2005 Express on xp. Is VWD the problem???? The major problem appears to be that when i run it shows in the Build Output "Could not create type 'xmlForAsp.Atlas.CustomerService in CustsomersService.asmx. I downloaded the vsi for the Empty template as u suggested, and added all your download files to it.

    ANY help would be appreciated because I spent a lot of hours trying to get there before I saw the post that let to your weblog.

    Thanks for any help.

    Pauley

  • Crying [:'(] Re: Atlas Demo Application and help with PushPins

    11-08-2005, 6:59 AM
    • Loading...
    • ofergal
    • Joined on 06-18-2002, 8:10 AM
    • IL
    • Posts 31

    Help a novice please.
    I ran your code after making it "AtlasWebSite" virtual directory http://localhost/AtlasWebSite/CustomersViewer.aspx

    And I get error
    ------------------------------------------------------------------------------------------
    Parser Error Message: Unrecognized attribute 'appliesTo'. Note that attribute names are case-sensitive.

    Source Error:


    Line 52:   <compilation debug="true">
    Line 53:    <buildProviders>
    Line 54:     <add extension=".script" type="Microsoft.Web.Compilation.ScriptBuildProvider" appliesTo="Web"/><!---->
    Line 55:    </buildProviders>
    Line 56:   </compilation>
     ----------------------------------------------------------------------------------
    When I take (appliesTo="Web") out (like I have seen in some forums) I get another error

    ----------------------------------------------------------------------------
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

    Stack Trace:


    [MissingFieldException: Field not found: 'System.Collections.Generic.KeyValuePair`2.Key'.]
       Microsoft.Web.UI.ScriptManager.RenderScriptScript() +0
       Microsoft.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +42
       System.EventHandler.Invoke(Object sender, EventArgs e) +0
       System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +2010340
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean
     
    --------------------------------------------------------------------
    What am I doing wrong?

  • Re: Atlas Demo Application and help with PushPins

    11-08-2005, 3:29 PM
    • Loading...
    • WilcoB
    • Joined on 03-02-2003, 8:02 AM
    • Posts 288
    You are probably using the beta 2 bits of Atlas, while running the RC/RTM bits of .NET. If that is the case, please get a version that supports your build of the framework from http://atlas.asp.net.
    - Wilco Bauwer (MSFT) / http://www.wilcob.com
Page 1 of 1 (13 items)