Thursday, August 31, 2006

Unfortunately (or fortunately) the Google Maps API version 2 has functions which return values, and are not properties. For example the GMap2 function fromLatLngToDivPixel(latlng) returns a GPoint.

There are two options to wrapping this sort of function in the control.


  1. Implement the calculation in C#. This requires recreating the functionality of the Google Map API within our control and goes further than merely wrapping the API. A number of functions could easily be implemented in this way, and this should be done in these cases (to reduce overheads associated with the next option I will discuss). But more complex functions may take a lot of understanding of the Google Map API which we do not have access to.

  2. Send the Javascript to the browser and have the Google Map API return the answer. This could be very messy and I believe requires some sort of method like Reverse Ajax, hence my research and previous blog post. I'll try to explain my ideas more clearly in the following diagram.


The diagram above is meant to represent the server handling a function which requires calls to these Google Map API functions which require returned values. The server starts processing as normal in response to the user, but at some point we need to call one of these value returning API functions. Possibly we inject the javascript for the function into the client browser, alongside some functions which return the value to the server once it is recieved from the API. The server can then use the returned value. I have shown 3 of these requests in the above diagram before the request is finally processed.


After looking at the problem for a while I think it is far too complex a solution and we would be better off going with the implementation in C# - for a start it would be better in the long run to really get real familiar with Google Maps!


My research into Ajax did make me reflect on why the GMap.Net Control uses it's own version of an Ajax implementation, which we have to maintain. It would make more sense to use a ready available framework. I thought as much and so started a branch to incorporate Anthem.Net (it's opensource as well, so you can contribute to that too!) in the GMap.Net Control. The branch can be checked out on SVN. I'll then merge it back in when it works, if it ever gets that far!


No comments: