Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


XML
<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
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>
Posted
Comments
F-ES Sitecore 3-Sep-15 4:19am    
If you can't get this working with the extensive documentation and samples, and all the samples available by searching the net, then maybe you'd be better using something like this

https://github.com/jmelosegui/GooglemapMvc
Member 11367931 3-Sep-15 4:34am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900