无法将变量作为地址传递到谷歌地图MVC

无法将变量作为地址传递到谷歌地图MVC

本文介绍了无法将变量作为地址传递到谷歌地图MVC 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

am trying to load google map by passing city name or address.




1 ) Map not displaying

2 ) How to load google map passing address or city name

3 ) How to load different location on mouse-over() that pass dynamic address







<script src="~/Scripts/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
     <script type="text/javascript">
            function codeAddress(address) {
                geocoder = new google.maps.Geocoder();
                geocoder.geocode({
                    'address': address
                }, function (results, status) {
                    if (status == google.maps.GeocoderStatus.OK) {
                        var myOptions = {
                            zoom: 8,
                            center: results[0].geometry.location,
                            mapTypeId: google.maps.MapTypeId.ROADMAP
                        }
                        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

                        var marker = new google.maps.Marker({
                            map: map,
                            position: results[0].geometry.location
                        });
                    }
                });
            }
        </script>
    <script type="text/javascript">
        $(".tiptext").mouseover(function () {
           // debugger;
            $(this).children(".description").show();
            codeAddress(address);
        }).mouseout(function () {
            $(this).children(".description").hide();

        });

    </script>




CSS:

    #map-canvas {
    width: 50%;
    height: 50%;
    margin: 0;
    padding:0px;
}
View:

    <div id="map_canvas">
    <div id="address">
@item.address
@item.city

    </div>
    </div>

推荐答案






CSS:

    #map-canvas {
    width: 50%;
    height: 50%;
    margin: 0;
    padding:0px;
}
View:

    <div id="map_canvas">
    <div id="address">
@item.address
@item.city

    </div>
    </div>


这篇关于无法将变量作为地址传递到谷歌地图MVC 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 01:26