How to change Bing Map code to Google Map code -
good day,
does have idea of how change bing map google map api code. have found useful code on line coded using bing maps , change work google maps. if found code here: http://blogs.msdn.com/b/crm/archive/2011/01/19/custom-charting-capabilities-in-microsoft-dynamics-crm-2011.aspx
code below:
<html> <head> <title>accounts on bing maps</title> <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="clientglobalcontext.js.aspx"></script> <script type="text/javascript"> var map; // function construct key-value pairs query string. function getparametersfromquery(query) { var parametersdictionary = new array(); var parameters = query.split('&'); (var = 0; < parameters.length; i++) { var keyandvalue = parameters[i].split('='); parametersdictionary[unescape(keyandvalue[0])] = unescape(keyandvalue[1]); } return parametersdictionary; } // function makes request crm rest end-point, , invokes callback results. function retrievefromcrmrestapi(url, callback) { $.ajax({ type: "get", url: getglobalcontext().getserverurl() + "/xrmservices/2011/organizationdata.svc" + url, contenttype: "application/json; charset=utf-8", datatype: "json", success: function (data) { callback(data.d); } }); } // function retrieves corresponding crm chart, , invokes callback when successful. function loadchartfromcrm(callback) { var parameters = getparametersfromquery(window.location.search.substring(1)); parameters = getparametersfromquery(parameters["data"]); var id = parameters["visid"].substr(1, 36); var type = parameters["vistype"]; var url = (type == "1111" ? "/savedqueryvisualizationset" : "/userqueryvisualizationset") + "(guid'" + id + "')?$select=datadescription,presentationdescription"; retrievefromcrmrestapi(url, callback); } var locations = new array(); function plotaccountlocations(accounts) { if (accounts.length > 0) { var account = accounts.pop(); var address = account.address1_city + ', ' + account.address1_country; map.find(null, address, null, null, 0, 1, false, false, false, false, function (shapelayer, results, places, moreresults, error) { if (null != places && places.length > 0) { var place = places[0]; var newshape = new veshape(veshapetype.pushpin, place.latlong); newshape.settitle(account.name); newshape.setdescription(address); locations.push(newshape); } // when have found (or not found) current account, // recursively call same function find next one. plotaccountlocations(accounts); }); } else { var shapelayer = new veshapelayer(); map.addshapelayer(shapelayer); shapelayer.addshape(locations); } } function loadaccountsfromcrm(datadescription) { var url = "/accountset?$select=address1_country,address1_city,name"; if (null != datadescription) { // filter accounts based on country specified in data description. url += "&$filter=address1_country eq '" + datadescription + "'"; } retrievefromcrmrestapi(url, function (data) { var results = data["results"]; var accounts = new array(); (resultkey in results) { accounts.push(results[resultkey]); } // once accounts retrieved crm server, plot locations on map. plotaccountlocations(accounts); } ); } function getmap(presentationdescription) { // set center , zoom defaults. var center = null; var zoom = 4; if (null != presentationdescription) { // calculate map-center , zoom presentation description. var arguments = presentationdescription.split(','); if (arguments.length > 1) { center = new velatlong(arguments[0], arguments[1]); } if (arguments.length > 2) { zoom = arguments[2]; } } map = new vemap("map"); map.loadmap(center, zoom, vemapstyle.road, true, vemapmode.mode2d, false, 0); window.onresize = function (event) { map.resize(document.body.clientwidth, document.body.clientheight); }; window.onresize(null); } function loadmap() { // first, chart object crm server. loadchartfromcrm( function (chart) { // once have retrieved chart, format map based on chart's presentation description. getmap(chart.presentationdescription); // accounts crm server based on chart's data description, , plot them on map. loadaccountsfromcrm(chart.datadescription); } ); } </script> </head> <body onload="loadmap()"> <div id="map"></div> </body> </html>
there no easy out of box solution looking for.
google api has many differences. example, google api leaves keeping track of map children programmer (you). there no means of looping through map controls there bing api. means solution saving map content , re-displaying little different.
although, since both api's done via javascript, need convert functionality according documentation;
Comments
Post a Comment