我想做的是以下事情:
因此,我有一个通常在博客平台中使用的json函数。
function new22(json) {
var htmlcode ='';
document.write( htmlcode );
for ( var i = 0; i < json.feed.entry.length; i++ ) {
for ( var j = 0; j < json.feed.entry[ i ].link.length; j++ ) {
if ( json.feed.entry[ i ].link[ j ].rel == 'alternate' ) {
var postUrl = json.feed.entry[ i ].link[ j ].href;
break;
}
}
var postTitle = json.feed.entry[i].title.$t;
var postThumbSize = 600;
var postThumb = json.feed.entry[i].media$thumbnail.url;
postThumb = postThumb.replace( '/s72-c/', '/s' + postThumbSize + '/' );
var postCategory = json.feed.entry[i].category[0].term;
var item = "[locationData('test.html', '___', '___', '_____', "1327 Intervale Ave, Bronx, NY ", "+38099231212", "5", "27"), 40.72956781, -73.99726866, 0, markerIcon],";
htmlcode += '';
document.write(item);
}
}
在上一个函数中,我可以针对我为特定帖子标签发布的博客帖子,替换静态值,例如将“ test.html”替换为“ + postTitle +”,“ postCategory”等。 ..
此函数,我可以使用以下javascript调用它,例如将其放入div中,例如....
<div id="123">
<script>
document.write("<script src=\"/feeds/posts/summary/-/<data:content/>?max-results=4&orderby=published&alt=json-in-script&callback=favouritePosts\"><\/script>");
</script></div>
加载html页面时,此javascript的结果为(2)
[locationData('bloggerpost1', '___', '___', '_____', "1327 Intervale Ave, Bronx, NY ", "+38099231212", "5", "27"), 40.72956781, -73.99726866, 0, markerIcon],locationData('bloggerpost2', '___', '___', '_____', "1327 Intervale Ave, Bronx, NY ", "+38099231212", "5", "27"), 40.72956781, -73.99726866, 0, markerIcon],].....
好的,到目前为止,一切都很好。 但是以下情况令人头疼。...
进入Google Map函数后,我能否获得上一个(2)结果并更新此函数的特定变量? 特别是,它具有以下功能,与Google地图相关
(function ($) {
"use strict";
var markerIcon = {
anchor: new google.maps.Point(22, 16),
url: 'images/marker.png',
}
function mainMap() {
function locationData(locationURL, locationCategory, locationImg, locationTitle, locationAddress, locationPhone, locationStarRating, locationRevievsCounter) {
return ('<div class="map-popup-wrap"><div class="map-popup"><div class="infoBox-close"><i class="fa fa-times"></i></div><div class="map-popup-category">' + locationCategory + '</div><a href="' + locationURL + '" class="listing-img-content fl-wrap"><img src="' + locationImg + '" alt=""></a> <div class="listing-content fl-wrap"><div class="card-popup-raining map-card-rainting" data-staRrating="' + locationStarRating + '"><span class="map-popup-reviews-count">( ' + locationRevievsCounter + ' reviews )</span></div><div class="listing-title fl-wrap"><h4><a href=' + locationURL + '>' + locationTitle + '</a></h4><span class="map-popup-location-info"><i class="fa fa-map-marker"></i>' + locationAddress + '</span><span class="map-popup-location-phone"><i class="fa fa-phone"></i>' + locationPhone + '</span></div></div></div></div>')
}
var locations=[[locationData('test.html', '___', '___', '_____', "1327 Intervale Ave, Bronx, NY ", "+38099231212", "5", "27"), 40.72956781, -73.99726866, 0, markerIcon],[locationData('listing-single.html', 'Conference and Events', 'images/all/1.jpg', 'Event In City Mol', "W 85th St, New York, NY ", "+38099231212", "4", "5"), 40.76221766, -73.96511769, 1, markerIcon]];
主地图函数有一个名为“ locations”的变量,其中有一种特定的形式,说明如何在Google地图中插入一个兴趣点。
因此,我想做的是,如果有可能,取决于具有特定标签的博客作者帖子,以便通过json feed创建总计为[[locationData('test.html',' ',' ','_____',“ 1327 Intervale Ave,Bronx,NY”,“ + 38099231212”,“ 5”,“ 27”),40.72956781,-73.99726866、0,markerIcon ]”元素。
这将是google map函数转换为可变位置的重要信息。我不知道是否有可能。我要做的第一件事是
var location= document.getElementById("123").innerHTML;
var locations= "["+location+"];";
但是它不起作用。谷歌地图是空的,没有任何兴趣点。有帮助吗????? 谢谢您的时间.....