Which API to use when starting with Bing Maps - c#

I've spent most of the Christmas reading through the Bing Maps information. However, there are so many different options and choices that I'm getting stuck on the plentifulness.
In one of the most obvious URLs I see both non-API and API approaches. That's confusing. There are AJAX, REST and Spacial Services and, to the best of my understanding, they do pretty much the same. That's confusing too... :)
So, here's the question. I'd like to create a web page that given a certain input (e.g. XML or JSON) will provide me with an image. The image is supposed to be a map with plotted pins (that contain my descriptions), controls for zoom/pan and (preferably) even traveling routes (automatically computed or provided by me) between those pins. Also, It'd be great if I could set a semi-transparent polygons covering some areas.
Which API am I supposed to use?!
I sis something like that a few years ago with Google Maps but as far I recall, I only sent in a XML file and the map was hosted more or less at Google's.

If you're building a web site, then you'll have to choose between the AJAX Control and the REST services. Basically, the AJAX Control allows you to embedded a map in your page, add pushpins, draw shapes, display routes...etc.
See http://www.bingmapsportal.com/ISDK/AjaxV7#CreateMap1 for a live demo.
The REST services are more useful for tasks simple like static imagery as well as requests like (reverse)geocoding and routing, that don't involve user interaction.
If you want a full "map control" that allows the user to interact with keyboard/mouse, use the AJAX API. If you're not, REST services could be enough.
EDIT:
AJAX API = AJAX control = AJAX v7
Spatial Data Services is a REST API that allows to compute spatial requests against a large number of data. It shouldn't be used to display a map.
If you're interested in something that allows your users to pan/zoom, create pushpins by clicking on the map...etc., then the AJAX control is the most suitable. It offers all the javascript stuff to display a dynamic map that allows user interaction.

If your XML file is in GeoRSS or GPX format then take a look at the modules for Bing Maps here which show you how to do this in a few lines of code: https://bingmapsv7modules.codeplex.com/
If your XML file is a custom format then take a look at the GeoRSS module to see how to read XML in JavaScript.
If you have more than a thousand items in your XML file I would highly recommend storing your data in the Bing Spatial Data Services which will expose it as a spatial REST service, or uploading it to a database and using a web service to load the data to the map. Loading more than 1,000 pushpins to a JavaScript map could be slow. Using a service you can load only the data that is in view which would make your app much faster.

Related

remove and add google map markers dynamically asp.net

I am new to asp.net and Google maps. I want to achieve tracking capability on my asp.net page. I want to create a number of markers and then move them along a path.
Can any one help me understand, how do I do it?
I want google maps to work as AJAX
this can be done in many ways, I will dish out a very easy solution,
1.Your webpage should load a map and add markers representing your assets with an id.
2. Your web page should ping your web server every sec to query for change
3. If your server has a change to report it should reply back with the latest latlon for those ids as a json
4.you can then update the positions of those markers.
If you can implement http push(long polling/websockets) then even better as you will get near realtime updates
This assumes that your web server is being updated by your tracking device.
your webservice should always return the latest position it has for the assets.
Updating your markers(assets) on client side is pretty easy as well,
To 'move' your existing marker, you'll wanna make sure its global and then you can just update its position within the function with something like:
marker.setPosition(results[0].geometry.location);

Parsing Data from a website in WP7

This website that keeps updating some live information about the bus timings in Helsinki.
I want to parse the live information from the website and display it on my WP7 phone. The user needs to enter the bus stop number and the WP7 app should show the buses/trams currently in the bus stop.
Is there any way I could obtain the real time information from the website?
If you look at the source of the website (http://www.omatlahdot.fi/omatlahdot/web?command=fullscreen&stop=1020455) -- in IE right-click on the page and select View Source -- you'll see that there's really very little in the actual source file, in particular none of the data is there. All of the hard work is coming from the referenced javascript file scripts/fullscreen_header.js (full path is http://www.omatlahdot.fi/omatlahdot/scripts/fullscreen_header.js). You want to download that .js file and study how it retrieves data with AJAX calls. Start with the reloadPage function.
You can make these same calls (e.g., using WebClient) to retrieve the data into your application. If you want to extract the data from the returned HTML, I'd consider parsing it simply as a string since I am assuming that it would have a very regular structure and dragging in a general-purpose HTML parser would probably be overkill.
Alternatively, you might find out if the omatlahodot.fi provides the data as JSON or XML feeds, so you don't have to "screen-scrape" the HTML. I don't read Finnish, so I can't help you with that. Look around on their websites (maybe a section called "dev" or "api") or send them an email inquiry.
Please let us know how it works out!

Creating a widget

Hi i want to create a widget which can be embedded on other websites similar to the twitter profile widget, an example is here;
http://twitter.com/about/resources/widgets/widget_profile
The way i would approach this is to return the data in json format via my wcf, the problem is looking at the twitter example there seems to be some javascript and i am not to clued up on the purpose. My question to the more experienced devlopers is am i on the right track and what else will i need to do. Thanks alot
The purpose of the javascript would be to actually call your wcf service to retrieve data and write the html results to the screen. In the twitter example, many options are set inside a javascript object that is used to manage the configuration (background color, username, etc). You can return json, and then take the values from json and plug them into an html template on the client side. If you want this to be used on other sites however, I would probably avoid the use of jquery as you can't be sure the user has included it, and so you would need to include it. And then you have versioning issues if you use an older version, and the website your widget is on wants to use a newer version.
There is an interesting blog post that explains how to create a widget, loading jquery and css safely, making JSONP calls and more:
How to build a web widget (using jQuery)

Bing Maps REST API Convert Coordinates to Zip Code or Similar

Bing Maps API has been great for figuring out all my GPS information sent from a WP7 phone. But I'm not sure how to deal with Zip Codes. I know it varies per country. I'm curious what is the best way to get a Zip code (or similar) from a latitude/longitude. Bing Maps doesn't always return a City with Area code. Sometimes it will bring back "Populated Area" such as the bay area or San Francisco. The zip node in the XML will be blank.
Are there hacks to get around this? Or am I looking at some other complicated calculation and a second web service call?
I ended up using the google api to get this type of information. I wanted to get the suburb I was in and Bing would not return this. May be worth a look to see if Google will return the zip code.
You can use the Locations API to get the location information for a specified point. If you only want the postal code for the specified location, then you just set the includeEntityTypes parameter to PostCode1, though you can request several as a comma-separated list.
As you are no doubt aware, you can also choose between an XML or JSON response.
I'm not sure if there's an easier way to do this with the API, but you can definitely accomplish this without using another service although it's a bit of extra work. You can add a custom tile layer using shape files such as the ones provided here: http://www.census.gov/geo/www/cob/zt_metadata.html

Google Maps - Easy way in ASP.Net?

I'm wanting to use google maps and see a million ways to do it on the web. Some are javascript methods and some are asp.net server components with which I have hit and miss luck. What's the easiest and most reliable way using c# and asp.net?
I have my location data including geocodes in a database. I want to provide users a method to do a lookup for certain locations. From there, my code will provide a table of geocodes to google maps with markers on the map corresponding to the found entries. Users can see each entry and need to be able to tell which is which if multiple rows are returned.
Is there a good way to do this?
The Google Maps API is accessed via JavaScript (any server controls are just abstracting this away from you). In the case you described, you would need to dynamically output the required JavaScript to tell the maps API what to display.
See http://dotnet.sys-con.com/node/171162
There are a few server controls to do it, like this, but you have to learn how to do things in one way (server control) or another (Javascript Google API).
I recommend using the Google API, since it has more samples all over the web, and you can use new features implemented by Google right after they release them and don't have to wait for the server control developer to do it.
I would recommend using direct JavaScript to create the Google Maps. It's fairly straight forward and then you will be able to understand what's going on behind the scenes.
Google has some pretty good tutorials and documentation to get you up and running quick. Once you add one to your site, it will become very easy to setup the rest of the customization that you need.
Take a look at this site for examples.
http://code.google.com/apis/maps/documentation/examples/
As usual I point to ComponentOne who has a nice SilverLight control for this that can use google-maps or Microsofts Live Maps, it uses Silverlight Deep Zoom to handle it nicely:
http://www.componentone.com/SuperProducts/MapsSilverlight/
Live example:
http://demo.componentone.com/Silverlight/Factories/
(I'm not from ComponentOne, just a satisfied customer) ;)
I know you can do it yourself with scripts and other ways, but its just so much more fun to use code allreade written. ;)
Best .NET Wrapper for Google Maps or Yahoo Maps?
BTW: I found a great post here that has an example on how to do a store lookup. Works really well. I recommend!!
http://blog.donnfelker.com/post/HOWTO-Build-a-Store-Locator-in-ASPNET.aspx
Check out this example: Data driven Google Maps in ASP.Net
I used ASP.Net Ajax to create a web-service that is callable from JavaScript.
The web-service talks to the database and fills a very basic object. ASP.Net Ajax, then makes the object available to my client javascript. The rest is easy: In the client, you call the webservice from Javascript, read the data returned and populate Google Maps, using simple Google Maps API calls.
Check out the site at link text
Please, try my GoogleMaps control for ASP.NET

Categories

Resources