lele24

Add Image for Start and End of the route

Discussion created by lele24 on Jan 3, 2012
hi everyone!

I am trying to add image for the start and end of the route as below but it only draw the route but image is not display. Someone please help me. Thanks!

if (i == 0 || i == historyNodes.length - 1) { //take out first point and last point
                                var offsets = SwitchIconPosition(iconPosition);
                                var XY_Offset = [];
                                XY_Offset = offsets.toString().split(",");

                                if (i == 0) {
                                  
                                    startLat = latitude; //parseFloat(historyNodes[i].LagLng.XY[0]);
                                    startLng = longitude; //parseFloat(historyNodes[i].LagLng.XY[1]);
                                    AddIcon(startLat, startLng, "img/StartPoint.gif, 15, 15");
                                    //alert(startLat + "+" + startLng);
                                    startTime = gpsDate;
                                    startLocation = streetName;
                                 
                                }
                                else (i == historyNodes.length - 1) // Last node
                                {
                                    endLat = latitude; //parseFloat(historyNodes[i].LagLng.XY[0]);
                                    endLng = longitude; //parseFloat(historyNodes[i].LagLng.XY[1]);
                                    AddIcon(endLat, endLng, "img/EndPoint.gif, 15, 15");
                                  
                                    stopTime = gpsDate;
                                    stopLocation = streetName;

                                    var triggerStr = historyNodes[i].Triggers;
                                    var trigger_bytes = [];
                                    trigger_bytes = triggerStr.toString().split(",");
                                    .............
                                    .............
                                    .............
                              }

function AddIcon(latitude, longitude, iconURL) {
            try {
                 //alert(latitude + "//" + longitude + "//" + iconURL); http://www.onemap.sg/ArcGIS/rest/services/Geometry/GeometryServer
                var host = "http://www.onemap.sg/";
                // alert("AddVehicle : " + "Device OID : " + deviceOid + " : " + deviceOid + "/vehiclePlate : " + vehiclePlate + "/gpsDate : " + gpsDate + "/latitude : " + latitude + "/longitude : " + longitude + "//" + streetName + "//" + heading + "//" + iconURL + "//");
                var gsvc = new esri.tasks.GeometryService(host + "ArcGIS/rest/services/Geometry/GeometryServer");
                //var geomPoint = new esri.geometry.Point(longitude, latitude, new esri.SpatialReference({ wkid: 4326 }));
                 
                //var pointSymbol = new esri.symbol.PictureMarkerSymbol('http://maps.gstatic.com/intl/en_sg/mapfiles/ms/micons/blue-dot.png', 20, 20);
                var pointSymbol = new esri.symbol.PictureMarkerSymbol(iconURL.split(",")[0], parseInt(iconURL.split(",")[1]), parseInt(iconURL.split(",")[2]));
                //var pointSymbol = new esri.symbol.PictureMarkerSymbol('img/VT012.gif', 15, 15);
                var graphic = new esri.Graphic(geomPoint, pointSymbol);
                var npr = new esri.SpatialReference({ wkid: 3414 });


                gsvc.project([graphic], npr, function(featres) {
                    var geomPoint1 = featres[0].geometry;
                    var graphic1 = new esri.Graphic(geomPoint1, pointSymbol);
                    OneMap.map.graphics.add(graphic1);

                });
            }
            catch (err) {
                //alert(err);
                var error = "Error description: " + err.description + "";
                EcoWebServer.WebService.WriteClientSideException("OneMapTrace.aspx", "AddIcon()", error);
            }
        }

Outcomes