Wednesday, July 17, 2013

Google Maps V3 to locate using Markers and drawer circle around in android


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Show/Add multiple markers to Google Maps in asp.net website</title>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript" src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
</script>
<script type="text/javascript">
    function initialize() {
        var markers = [
{
 
    "lat": 1.319451,
    "lng": 103.82734,

},
{

    "lat": 1.288743,
    "lng": 103.805412,

},
{

    "lat": 1.299816,
    "lng": 103.855924,

},
];
        var mapOptions = {
            center: new google.maps.LatLng(1.3663888889, 103.8647222222),
            zoom: 10,
            mapTypeId: google.maps.MapTypeId.ROADMAP
            //  marker:true
        };
        var infoWindow = new google.maps.InfoWindow();
        var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
        for (i = 0; i < markers.length; i++) {
            var data = markers[i]
            var myLatlng = new google.maps.LatLng(data.lat, data.lng);
            var marker = new google.maps.Marker({
                position: myLatlng,
                position1:new google.maps.LatLng(1.319451, 103.82734),

                map: map,
                title: data.title
            });
            (function (marker, data) {

                // Attaching a click event to the current marker
                google.maps.event.addListener(marker, "click", function (e) {
                    infoWindow.setContent(data.description);
                    infoWindow.open(map, marker);
                });
            })(marker, data);
         
       circle = new google.maps.Circle({
       map: map,
        radius: 5000,    // 1 miles in metres = 1609.3 m
        strokeWeight: 1,
        strokeOpacity: 0.3,
        fillOpacity: 0.2,
        fillColor: '#A3A3C2'
    });
   circle.bindTo('center', marker, 'position1');
        }
    }
</script>
</head>
<body onload="initialize()">
<form id="form1" runat="server">
<div id="map_canvas" style="width: 500px; height: 400px"></div>
</form>
</body>
</html>

No comments:

Post a Comment