Skip to content

Instantly share code, notes, and snippets.

@nickjs
Created November 14, 2008 10:40
Show Gist options
  • Save nickjs/24855 to your computer and use it in GitHub Desktop.
Save nickjs/24855 to your computer and use it in GitHub Desktop.
@implementation LEMapView : CPView
{
id _map;
CPPoint _point;
int _zoom @accessors(property=zoom);
}
+ (void)initialize
{
/*
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAx-mGANmhS45KIpKzZMzZlhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTmElAgBq8IIAyt2v5sDtnbLBOtzQ";
document.body.appendChild(script);*/
}
- (LEMapView)initWithFrame:(CPRect)frame
{
self = [super initWithFrame:frame];
if(self)
{
if (GBrowserIsCompatible()) {
_map = new GMap2(_DOMElement);
_zoom = 13;
_point = CGPointMake(0,0);
}
}
return self;
}
- (CPPoint)point
{
return _point;
}
- (void)setPoint:(CPPoint)point
{
_point = point;
[self drawMap:self];
}
- (void)setPointFromString:(CPString)string
{
var geocoder = new GClientGeocoder();
geocoder.getLatLng(string, function(point) {
if (!point) {
alert(string + " not found");
} else {
_point.x = point.lat();
_point.y = point.lng();
[self drawMap:self];
}
});
}
- (void)drawMap:(id)sender
{
_map.setCenter(new GLatLng(_point.x, _point.y), _zoom);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment