0

So I am using JavaScript to plot a position of a flight and its flight path on a visualisation map. I am getting the data from a node server that I have created. I have looked at similar question on stack over flow but I haven't been able to get them working.

I am currently struggling with the positioning of the flight icon, as I want it to point in the same direction as the flight path or even put a marker at the top of the image so it can point to a certain latitude and longitude. At the minute the flight icon only faces north.

Here is a screenshot of my code. I tried using the anchor in the Google maps API but I couldn't get it working so I commented it out.

var flightCord = [];


    for (var i = 0; i < data.flight.length; i++) {

        var lat = data.flight[0].lat1;
        var lng = data.flight[0].lng1;

        // Co-ordinates for Dublin Airport 53.421379,   -6.27

        var image = new google.maps.MarkerImage("plane3.png"
        //new google.maps.Size(25,25),
        //null, null,
        //new google.maps.Point(53.4213879,-6.27)
        //new google.maps.Point(0, 50)

        );

        var latLng = new google.maps.LatLng(lat,lng);
        var marker = new google.maps.Marker({
        position: latLng,
        map: map,
        icon: image
         });

        var flightCord = [
        {lat:data.flight[0].lat1, lng: data.flight[0].lng1},
        {lat:data.flight[i].lat1, lng:data.flight[i].lng1}];

     }

         var flightPath = new google.maps.Polyline({
             path: flightCord,
             geodesic: true,
             strokeColor: '#FF0000',
             strokeOpacity: 1.0,
             strokeWeight: 1
         });
geocodezip
  • 158,664
  • 13
  • 220
  • 245
Men.P
  • 11
  • Not the problem, but the `MarkerImage` class was deprecated a long time ago. Please provide a [mcve] than demonstrates your issue. – geocodezip Apr 03 '17 at 11:02
  • Possible duplicate of [rotate a .gif image on google maps api v3](http://stackoverflow.com/questions/38723573/rotate-a-gif-image-on-google-maps-api-v3) – geocodezip Apr 03 '17 at 11:07
  • My answer here : http://stackoverflow.com/questions/43039148/pulse-animation-on-existing-markers-google-maps/43043045#43043045 shows how to get markers onto their own layer. I have also resorted to adding a # to the end of the icon URL with something identifiable in order to select it in the DOM to perform animations on it. Perhaps by adding the flight number? I can go into a bit more detail in an answer if needed, but probably a bit short of full working code. – Paul Thomas Apr 03 '17 at 11:38

0 Answers0