tags:

views:

68

answers:

3

Has anyone seen an example of using the YahooMaps API in silverlight (2.0)? Specifically the JSON API? Yahoo publishes tutorial for Flash but not SL. I am trying to understand how to process the JSON reply from the server, which looks something like this:

var YAHOO=window.YAHOO||{}; YAHOO.namespace=function(_1){ if(!_1||!_1.length){ return null; } var _2=_1.split("."); var _3=YAHOO; for(var i=(_2[0]=="YAHOO")?1:0;i<_2.length;++i){ _3[_2[i]]=_3[_2[i]]||{}; _3=_3[_2[i]]; } return _3; }; YAHOO.namespace("util"); YAHOO.namespace("widget"); YAHOO.namespace("example");

var YMAPPID = "mykey...."; function _ywjs(inc) { var o='<'+'script src="'+inc+'"'+' type="text/javascript"><'+'/script>'; document.write(o); }_ywjs('zttp://l.yimg.com/d/lib/common/utils/2/dom_2.0.1-b2.js'); _ywjs('zttp://l.yimg.com/d/lib/common/utils/2/event_2.0.0-b2.js'); _ywjs('zttp://l.yimg.com/d/lib/common/utils/2/dragdrop_2.0.1-b4.js'); _ywjs('zttp://l.yimg.com/d/lib/common/utils/2/animation_2.0.1-b2.js'); _ywjs('zttp://l.yimg.com/d/lib/map/js/api/ymapapi_3_8_2_3.js');<!-- xm3.maps.re3.yahoo.com uncompressed/chunked Thu Jul 16 16:18:46 PDT 2009 -->

(replace zttp with http in the above code, this web page things I'm spamming)

Failing that, what about OpenStreetMaps?

A: 

OpenStreetMaps works just fine in the new Silverlight Map control.

FlappySocks
A: 

BaseUri= "http://us.maps2.yimg.com/us.png.maps.yimg.com/png?v=3.52&amp;t=m&amp;x={0}&amp;y={1}&amp;z={2}";

public override Uri GetUri(int x, int y, int zoomLevel) { double posY; double zoom; checked { zoom = 18 - zoomLevel; } double num4 = Math.Pow(2.0, zoomLevel)/2.0;

        if (y < num4)
            posY = (num4 - Convert.ToDouble(y)) - 1.0;
        else
            posY = ((Convert.ToDouble(y) + 1) - num4)*-1.0;
        return new Uri(String.Format(CultureInfo.InvariantCulture, UriFormat, x, posY, zoom));
    }
focuswhere
A: 

If you're using Silverlight, a Microsoft technology, why not use the Bing / Virtual Earth mapping SDK. I think it would be a lot easier to use if you're doing anything but the most trivial display of a map. I haven't used it recently, but did a little toying around with it when it was still a CTP. Seemed really easy to add custom controls and styles to the map (say you wanted to mark locations with a push pin).

Here's a recent article I found that should give you a quickstart on it.

http://www.bing.com/community/blogs/maps/archive/2009/11/09/bing-maps-silverlight-control-1-0-released.aspx

James Hollister