如何将变量的值用于谷歌地图,以便它在地图上显示该地点

How can i use a variable's value for the google map so that it shows the place on map

本文关键字:地图 显示 变量 谷歌地图 用于      更新时间:2023-09-26

我有一个菜单,点击页面应该打开的任何地方都有不同的地方,其中包含与页面相关的详细信息以及在地图上显示该地点的谷歌地图。 但是我创建了一个页面,该页面根据其id显示不同地方的不同数据。 所以任何人都可以帮助我弄清楚如何使用该id来显示不同的谷歌地图不同的地方。

把它放在你的标题中...

<script>
    $(document).ready(function(){
        $("AddressView").each(function(){                         
            var embed ="<iframe style='margin-left:10px' width='215' height='215' frameborder='0' scrolling='no'  marginheight='0' marginwidth='0' src='https://maps.google.com/maps?&amp;q="+ encodeURIComponent( $(this).text() ) +"&amp;output=embed&iwloc'></iframe>";
               $(this).html(embed);
        });
    });
</script>

并把它放在你想显示地图的地方......

<AddressView>
    <?php echo (preg_replace('/'s+/', '', $POSTCODEVAR)); ?>
</AddressView>

根据需要更改样式。