Last active
August 29, 2015 14:01
-
-
Save fraserxu/59333ad756ea738fb649 to your computer and use it in GitHub Desktop.
A simple angularjs directive to open a link with system map client
This file contains hidden or 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
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'); | |
}); | |
} | |
} | |
}; | |
}); |
This file contains hidden or 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
<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