Google Maps Api:根据行的百分比放置标记

时间:2015-12-24 13:59:56

标签: google-maps google-maps-api-3

我在两点之间有一条线,我想根据该线的百分比放置一个标记,例如.. 我已达到路径的20%,在该行中放置一个标记,该路径对应于路径的20%。

怎么可能?

到目前为止我的代码:

var myCenter = new google.maps.LatLng(51.508742, -0.120850);
    function initialize() {
        var mapProp = {
            center: myCenter,
            zoom: 1,
            panControl: true,
            zoomControl: false,
            mapTypeControl: true,
            scaleControl: false,
            streetViewControl: false,
            overviewMapControl: true,
            rotateControl: false,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
        var flightPlanCoordinates = [
            <?php
            $login = $_SESSION['login'];
            $FindIt = $db_account->query("SELECT * FROM main.flights WHERE owner='$login'");
            $counter = $FindIt->rowCount(PDO::FETCH_ASSOC);
            while($route = $FindIt->fetch()){
                $route = $route['route'];
                $Get = $db_account->query("SELECT * FROM main.routes WHERE route='$route'");
                $row = $Get->fetch();
                $departure = $row['start'];
                $arrival = $row['end'];
                //frm
                //((latF-lati)2+(LonF-Longi)2)*44.56
                if($counter == 1){
                    echo "new google.maps.LatLng(".$departure."),";
                    echo "new google.maps.LatLng(".$arrival.")";
                }else{
                    echo "new google.maps.LatLng(".$departure."),";
                    echo "new google.maps.LatLng(".$arrival."),";
                }

            }

            ?>
          ];
        //distance calculations
        var n1
        var myPlane = new google.maps.LatLng();
        var marker = new google.maps.Marker({
            position: myPlane,
            map: map,
            title: 'route name'
          });

        var flightPath = new google.maps.Polyline({
            path: flightPlanCoordinates,
            strokeColor: "#FF0000",
            strokeOpacity: 1.0,
            strokeWeight: 2,
            geodesic: true
        });

        flightPath.setMap(map);
    }
    google.maps.event.addDomListener(window, 'load', initialize);

0 个答案:

没有答案