VinylFox / ExtJS.ux.GMapPanel

An ExtJS Panel that displays a Google Map using the Google Maps API
http://www.vinylfox.com
64 stars 35 forks source link

Refactoring the API #2

Open Drachenkaetzchen opened 13 years ago

Drachenkaetzchen commented 13 years ago

Hi,

I'm working with GMapPanel3 for a few days now, and there are a few issues that came into my attention. The API seems to be tied to a specific behavior, e.g. if you call geoCodeLookup(), it always centers the map to the found address, with no or limited possibilities to do custom stuff. IMHO geoCodeLookup should simply lookup the given address, and calling a callback afterwards, instead of trying to center the map all the time, which is probably not what the developer needs.

I might refactor the API on my fork, but if you have suggestions or things that you want to have changed, we could work together on that.

cheers, Timo

abraxxa commented 13 years ago

I have a custom GMapPanel3 version in use since about a year which adds the feature to remember all markers and center + zoom the map so all of them are visible. I had'nt enough time to fork the current version so it gets merged into the main version but I'd contribute my code if you like to look into it.

VinylFox commented 13 years ago

tim, the geoCodeLookup accepts a center argument that is a bool that decides to center the map or not:

geoCodeLookup : function(addr, marker, clear, center, listeners)

If this is not working, then that would be a bug.

I'm certainly open to pulling in changes that you have, as long as they are generic changes that can be used by all. In other words, nothing that is specific to your usage.

Drachenkaetzchen commented 13 years ago

Well, IMHO most functions do too much.

For example, I expect that geoCodeLookup only triggers an address lookup via the geocoder, then doing a callback to the function which decides what to do then. Instead, geoCodeLookup has "hardwired" actions (center, marker, clear etc) which makes it difficult to add custom callbacks.

Also, quite some methods have a huge parameter list (where huge is 4 or more parameters) which makes it difficult to handle.

I will try to refactor the API to make it simpler to use, but I don't think I can keep API compatibility, at least not for GMapPanel3 (which I'm using).

Drachenkaetzchen commented 13 years ago

I just pushed my first additions to my fork. I try to maintain API compatibility.

New methods: setMapCenter - centers the map on the given google.maps.LatLng coordinate getGeocoder - returns an instance of the geocoder lookupAddress - looks up the coordinates for a given address and calls back an user-supplied function

Mazzo commented 12 years ago

I agree with timoahummel. geoCodeLookup() should have a callback where to handle the LatLng data.

I had to modify the method behaviour to accept a zoom value to use after centering. Obviuosly this is going to break on next release.