Ash*_*mar 14 javascript jquery android google-maps google-maps-api-3
这是我在谷歌地图V3上逐一删除每个标记的简单工作示例.当标记添加到Google Map时,我设置了Drop Animation.
但我想使用任何Javascript Stuff或其他库自定义Drop with Fade Animation?
谷歌在命名空间中有这个选项我们可以在命名空间中添加自定义动画选项吗?
我的Google地图V3工作代码
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
</head>
<body>
<div id="map" style="width: 500px; height: 400px;"></div>
<script type="text/javascript">
var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(-33.92, 151.25),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
function marker(i) {
if (i > locations.length) return;
var marker;
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
animation: google.maps.Animation.DROP,
map: map
});
var t=setTimeout("marker("+(i+1)+")",500);
}
marker(0);
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我已经走了多远。Google Maps API 从http://maps.gstatic.com/cat_js/intl/en_us/mapfiles/api-3/14/4/%7Bcommon,map,util,marker%7D内部在页面上添加了一个 CSS 关键帧片段.js
在页面内它看起来像这样
@-webkit-keyframes _gm2657 {
0 % {
-webkit-transform: translate3d(0px, 0px, 0); -webkit-animation-timing-function: ease-out;
}
50 % {
-webkit-transform: translate3d(0px, -20px, 0); -webkit-animation-timing-function: ease-in ;
}
100 % {
-webkit-transform: translate3d(0px, 0px, 0); -webkit-animation-timing-function: ease-out;
}
Run Code Online (Sandbox Code Playgroud)
}
里面的函数被压缩为
function uJ(a, b) {
var c = [];
c[A]("@-webkit-keyframes ", b, " {\\n");
K(a.b, function (a) {
c[A](100 * a[$k], "% { ");
c[A]("-webkit-transform: translate3d(", a[Fv][0], "px,", a[Fv][1], "px,0); ");
c[A]("-webkit-animation-timing-function: ", a.wa, "; ");
c[A]("}\\n")
});
c[A]("}\\n");
return c[Mc]("")
}
Run Code Online (Sandbox Code Playgroud)
我现在无法再深入研究以找出如何入侵该对象。
问题是我不知道他们是如何构建关键帧动画名称的。我已经a.d="_gm"+l[B](1E4*l[Qb]())从上面的文件中获得了尽可能多的信息,但祝你好运,将其追溯到 l[B] 是什么,或者 1E4*l 等同于什么对象,或者 Qb 是如何定义的。
我的下一条路线是抓取包含 @-webkit-keyframes _gm 的脚本标签的 HTML 并查看如何提取使用的数字,然后使用它来编写您自己的关键帧动画,并希望谷歌地图使用您注入的 CSS 而不是它自己的.
沿着这些路线,我编写了一个小的 jQuery 方法来搜索具有部分匹配“_gm”的样式属性的所有 div。
var poll;
var ntrvl = setInterval(function () {
poll = $("div[style*=' _gm']");
if (poll.length > 0) {
craftNewAnimation(poll.css('-webkit-animation-name'));
clearInterval(ntrvl);
}
}, 10);
function craftNewAnimation(name) {
console.log(name);
var markup = ['<style>',
'@-webkit-keyframes ' + name + ' {',
'0%{ opacity: 0; }',
'100%{ opacity: 1; }',
'}',
'</style'
];
$('body').append(markup.join(""));
}
Run Code Online (Sandbox Code Playgroud)
http://jsbin.com/uJAdaJA/3/edit
由于某种原因,它不会替换它检测到的第一个动画。并且可能还有其他方法可以在没有太多黑客攻击的情况下获得这个神奇的关键帧名称。
祝你好运。
| 归档时间: |
|
| 查看次数: |
28480 次 |
| 最近记录: |