Created
October 9, 2009 05:37
-
-
Save j4johnfox/205742 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
{var the_class = objj_allocateClassPair(MKMapItem, "MKMarker"), | |
meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_gMarker"), new objj_ivar("_location"), new objj_ivar("_draggable"), new objj_ivar("_withShadow"), new objj_ivar("_iconUrl"), new objj_ivar("_shadowUrl"), new objj_ivar("_delegate")]); | |
objj_registerClassPair(the_class); | |
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path)); | |
class_addMethods(the_class, [new objj_method(sel_getUid("gMarker"), function $MKMarker__gMarker(self, _cmd) | |
{ with(self) | |
{ | |
return _gMarker; | |
} | |
},["id"]), | |
new objj_method(sel_getUid("setGMarker:"), function $MKMarker__setGMarker_(self, _cmd, newValue) | |
{ with(self) | |
{ | |
_gMarker = newValue; | |
} | |
},["void","id"]), | |
new objj_method(sel_getUid("location"), function $MKMarker__location(self, _cmd) | |
{ with(self) | |
{ | |
return _location; | |
} | |
},["id"]), | |
new objj_method(sel_getUid("setLocation:"), function $MKMarker__setLocation_(self, _cmd, newValue) | |
{ with(self) | |
{ | |
_location = newValue; | |
} | |
},["void","id"]), | |
new objj_method(sel_getUid("draggable"), function $MKMarker__draggable(self, _cmd) | |
{ with(self) | |
{ | |
return _draggable; | |
} | |
},["id"]), | |
new objj_method(sel_getUid("setDraggable:"), function $MKMarker__setDraggable_(self, _cmd, newValue) | |
{ with(self) | |
{ | |
_draggable = newValue; | |
} | |
},["void","id"]), | |
new objj_method(sel_getUid("withShadow"), function $MKMarker__withShadow(self, _cmd) | |
{ with(self) | |
{ | |
return _withShadow; | |
} | |
},["id"]), | |
new objj_method(sel_getUid("setWithShadow:"), function $MKMarker__setWithShadow_(self, _cmd, newValue) | |
{ with(self) | |
{ | |
_withShadow = newValue; | |
} | |
},["void","id"]), | |
new objj_method(sel_getUid("iconUrl"), function $MKMarker__iconUrl(self, _cmd) | |
{ with(self) | |
{ | |
return _iconUrl; | |
} | |
},["id"]), | |
new objj_method(sel_getUid("setIconUrl:"), function $MKMarker__setIconUrl_(self, _cmd, newValue) | |
{ with(self) | |
{ | |
_iconUrl = newValue; | |
} | |
},["void","id"]), | |
new objj_method(sel_getUid("shadowUrl"), function $MKMarker__shadowUrl(self, _cmd) | |
{ with(self) | |
{ | |
return _shadowUrl; | |
} | |
},["id"]), | |
new objj_method(sel_getUid("setShadowUrl:"), function $MKMarker__setShadowUrl_(self, _cmd, newValue) | |
{ with(self) | |
{ | |
_shadowUrl = newValue; | |
} | |
},["void","id"]), | |
new objj_method(sel_getUid("delegate"), function $MKMarker__delegate(self, _cmd) | |
{ with(self) | |
{ | |
return _delegate; | |
} | |
},["id"]), | |
new objj_method(sel_getUid("setDelegate:"), function $MKMarker__setDelegate_(self, _cmd, newValue) | |
{ with(self) | |
{ | |
_delegate = newValue; | |
} | |
},["void","id"]), new objj_method(sel_getUid("initAtLocation:"), function $MKMarker__initAtLocation_(self, _cmd, aLocation) | |
{ with(self) | |
{ | |
if (self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("MKMapItem") }, "init")) { | |
_location = aLocation; | |
_withShadow = YES; | |
_draggable = YES; | |
} | |
return self; | |
} | |
},["id","MKLocation"]), new objj_method(sel_getUid("updateLocation"), function $MKMarker__updateLocation(self, _cmd) | |
{ with(self) | |
{ | |
_location = objj_msgSend(objj_msgSend(MKLocation, "alloc"), "initWithLatLng:", _gMarker.getLatLng()); | |
if (_delegate && objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("mapMarker:didMoveToLocation:"))) { | |
objj_msgSend(_delegate, "mapMarker:didMoveToLocation:", self, _location); | |
} | |
} | |
},["void"]), new objj_method(sel_getUid("setGoogleIcon:withShadow:"), function $MKMarker__setGoogleIcon_withShadow_(self, _cmd, anIconName, withShadow) | |
{ with(self) | |
{ | |
_withShadow = withShadow; | |
if (anIconName) { | |
_iconUrl = "http://maps.google.com/mapfiles/ms/micons/" + anIconName + ".png" | |
if (withShadow) { | |
if (anIconName.match(/dot/) || anIconName.match(/(blue|green|lightblue|orange|pink|purple|red|yellow)$/)) { | |
_shadowUrl = "http://maps.google.com/mapfiles/ms/micons/msmarker.shadow.png"; | |
} else if (anIconName.match(/pushpin/)) { | |
_shadowUrl = "http://maps.google.com/mapfiles/ms/micons/pushpin_shadow.png"; | |
} else { | |
_shadowUrl = "http://maps.google.com/mapfiles/ms/micons/" + anIconName + ".shadow.png"; | |
} | |
} | |
} else { | |
_iconUrl = nil; | |
_shadowUrl = "http://maps.google.com/mapfiles/ms/micons/msmarker.shadow.png"; //default shadow | |
} | |
} | |
},["void","CPString","BOOL"]), new objj_method(sel_getUid("setGoogleIcon:"), function $MKMarker__setGoogleIcon_(self, _cmd, anIconName) | |
{ with(self) | |
{ | |
objj_msgSend(self, "setGoogleIcon:withShadow:", anIconName, YES); | |
} | |
},["void","CPString"]), new objj_method(sel_getUid("addToMapView:"), function $MKMarker__addToMapView_(self, _cmd, mapView) | |
{ with(self) | |
{ | |
var googleMap = objj_msgSend(mapView, "gMap"); | |
var gm = objj_msgSend(MKMapView, "gmNamespace"); | |
var icon = new gm.Icon(gm.DEFAULT_ICON); | |
// set a different icon if the _iconUrl is set | |
if (_iconUrl) { | |
icon.image = _iconUrl; | |
icon.iconSize = new gm.Size(32, 32); | |
icon.iconAnchor = new gm.Point(16, 32); | |
} | |
// set the shadow | |
if (_withShadow && _shadowUrl) { | |
icon.shadow = _shadowUrl; | |
icon.shadowSize = new gm.Size(59, 32); | |
} | |
var markerOptions = { "icon":icon, "clickable":false, "draggable":_draggable }; | |
_gMarker = new gm.Marker(objj_msgSend(_location, "googleLatLng"), markerOptions); | |
gm.Event.addListener(_gMarker, 'dragend', function() { objj_msgSend(self, "updateLocation"); }); | |
googleMap.addOverlay(_gMarker); | |
} | |
},["void","MKMapView"]), new objj_method(sel_getUid("encodeWithCoder:"), function $MKMarker__encodeWithCoder_(self, _cmd, coder) | |
{ with(self) | |
{ | |
objj_msgSend(coder, "encodeObject:forKey:", [objj_msgSend(_location, "latitude"), objj_msgSend(_location, "longitude")], "location"); | |
} | |
},["void","CPCoder"])]); | |
class_addMethods(meta_class, [new objj_method(sel_getUid("marker"), function $MKMarker__marker(self, _cmd) | |
{ with(self) | |
{ | |
return objj_msgSend(objj_msgSend(MKMarker, "alloc"), "init"); | |
} | |
},["MKMarker"])]); | |
} | |
/**/ | |
//@ sourceURL=Frameworks/MapKit/MKMarker.j | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment