Skip to content

Instantly share code, notes, and snippets.

@fraserxu
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fraserxu/59333ad756ea738fb649 to your computer and use it in GitHub Desktop.
Save fraserxu/59333ad756ea738fb649 to your computer and use it in GitHub Desktop.
A simple angularjs directive to open a link with system map client
app.directive('mapScheme', function($window) {
return {
restrict: 'A',
link: function(scope, element, attr) {
if (attr.mapScheme != null) {
element.on('click', function() {
$window.open(encodeURI(attr.mapScheme), '_system', 'location=no');
});
}
}
};
});
<p>
Test with links:
<a map-scheme="http://maps.apple.com/?ll=31.228666, 121.434493" href="">
Link to Apple maps
</a>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment