Yes, that is similar to what I did for Bing. I wonder if you could add the
options after the provider list when mxn.js declared? That would get the option
where they need to be.
From: mapstraction-bounces at lists.mapstraction.com
[mailto:mapstraction-bounces at lists.mapstraction.com] On Behalf Of Adam
DuVander
Sent: Monday, September 20, 2010 3:10 PM
To: mapstraction at lists.mapstraction.com
Subject: Re: [Mapstraction] API Keys in code instead of the URL
Steve,
Thanks for starting a discussion about API keys that are passed via code,
instead of the URL. I changed the subject, hoping some devs with interests
beyond Bing take part in the discussion. I think Mapstraction needs a way to
handle this issue.
CloudMade also passes the API key. We''ve got around this with a global
cloudmade_key variable declared before the call to Mapstraction. You can see it
in action in the sandbox:
http://mapstraction.appspot.com/#cloudmade
This goes beyond the key. Google Maps V3 passes a number of options when the map
is instantiated, including the center and zoom. I think we should add an
optional "options" parameter to the mxn.Mapstraction constructor. This
could contain key(s), initial settings and more. We could even move the current
"debug" parameter to be an option (debug: true). And we should be able
to make that backwards compatible.
Any downsides to this proposal?
--Adam
On Fri, Sep 17, 2010 at 5:06 PM, Mitchell, Steve <Steve.Mitchell at
garmin.com<mailto:Steve.Mitchell at garmin.com>> wrote:
This is problematic: http://msdn.microsoft.com/en-us/library/ee692181.aspx
Bing doesn?t let you pass in a key on the URL like Google does. Any suggestions
how to do this with Mapstraction? What makes this tricky is that the key needs
to be available in the mxn.microsoft.core.js file before
this.maps[api].LoadMap() is called, meaning Options won?t work.
I can only think of a couple of ways to solve this.
1. Change mxn.microsoft.core.js to look for a variable in scope (see example
below).
if(mapkey) {
this.maps[api]. SetCredentials(mapkey);
}
this.maps[api].LoadMap();
2. Change the constructor, but that would break encapsulation.
var Mapstraction = mxn.Mapstraction = function(element, api, debug, key)
Thoughts?
For the moment, I?m going with option 1 as show below.
<script type="text/javascript">
var mapkey = ''#{resourceBundleRetriever.bingApiKey}'';
</script>
<script
src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"
type="text/javascript"/>
<script type="text/javascript" charset="utf-8"
src="http://mapstraction.googlecode.com/svn/trunk/source/mxn.js?(microsoft)"></script>
Any thoughts on another way to do this?
Steve
________________________________
This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient. If you are not the intended recipient, please be
aware that any disclosure, copying, distribution or use of this e-mail or any
attachment is prohibited. If you have received this e-mail in error, please
contact the sender and delete all copies.
Thank you for your cooperation.
_______________________________________________
Mapstraction mailing list
Mapstraction at lists.mapstraction.com<mailto:Mapstraction at
lists.mapstraction.com>
http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20100920/e696166d/attachment-0001.htm>