Thank you for resolving the previous issue.
I kept code for infobubbles click functionality , It is creating new infobubble other than replacing the Points A and B. For your reference I changed the latitude and longitude for point B. when you click on blank infobubble, then it will show content, but I need to show this content when we click on Point B and How to display default content for point A.
Otherwise is there any default content for both Point A and B, after showing the route? If default content is available by nokia maps api, how it should be integrated in my code.
If you don't mind, Please see the below code and tell me the changes to do.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Route - Nokia Maps API Example</title>
</head>
<body>
<div id="map" style="width:800px; height:600px;"></div>
<script src="http://api.maps.nokia.com/2.1.1/jsl.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var searchManager = new nokia.maps.search.Manager();
searchManager.addObserver("state", function (observedManager, key, value) {
// If the search has finished we can process the results
if (value == "finished") {
// We check that at least one location has been found
if (observedManager.locations.length == 1) {
// alert (observedManager.locations[0].displayPosition);
var lat = observedManager.locations[0].displayPosition.latitude;
var lon = observedManager.locations[0].displayPosition.longitude;
doRouting(lat, lon); // This is a function Call
} else {
var lat = observedManager.locations[0].displayPosition.latitude;
var lon = observedManager.locations[0].displayPosition.longitude;
// mylat = lat;
doRouting(lat, lon); // This is a function Call
}
} else if (value == "failed") {
alert("The search request failed.");
}
});
var proximity = {
// center: new nokia.maps.geo.Coordinate(28.51434, 77.01219),
radius: 1500 // search radius defined in meters
};
var searchTerm = "Akdeniz";
searchManager.geocode(searchTerm, proximity);
var map = new nokia.maps.map.Display(
document.getElementById("map"), {
components: [new nokia.maps.map.component.Behavior()],
zoomLevel: 11,
center: [38.4188500, 27.1287200]
}
);
function doRouting(lat, lon) {
// Create waypoints
var infoBubbles = new nokia.maps.map.component.InfoBubbles();
map.addComponent( infoBubbles);
//map.removeComponent(map.getComponentById("zoom.MouseWheel"));
// Create a route controller
var router = new nokia.maps.routing.Manager()
// Create waypoints
alert(lat);
alert(lon);
var waypoints = new nokia.maps.routing.WaypointParameterList();
waypoints.addCoordinate(
new nokia.maps.geo.Coordinate(lat,lon)
);
waypoints.addCoordinate(
new nokia.maps.geo.Coordinate(38.4188500, 27.1287200)
);
var modes = [{
type: "shortest",
transportModes: ["car"],
options: "avoidTollroad",
trafficMode: "default"
}];
var onRouteCalculated = function (observedRouter, key, value) {
if (value == "finished") {
var routes = observedRouter.getRoutes();
// Create the default map representation of a route
var mapRoute = new nokia.maps.routing.component.RouteResultSet(routes[0]).container;
map.objects.add(mapRoute);
// Zoom to the bounding box of the route
map.zoomTo(mapRoute.getBoundingBox(), false, "default");
} else if (value == "failed") {
alert("The routing request failed.");
}
};
// Add the observer function to the router's "state" property
router.addObserver("state", onRouteCalculated);
// Calculate the route (and call onRouteCalculated afterwards)
router.calculateRoute(waypoints, modes);
function addInfoBubble(infoBubbles, marker, html) {
marker.html = html;
marker.addListener("click" , function(evt) {
infoBubbles.addBubble(evt.target.html, evt.target.coordinate);
}, false);
}
var marker;
var markers = new Array();
marker = new nokia.maps.map.StandardMarker(new nokia.maps.geo.Coordinate(lat,lon));//lat,lon
addInfoBubble( infoBubbles, marker, "<div><a href='http://www.mcfc.co.uk' >Manchester City</a></div><div >City of Manchester Stadium<br>Capacity: 48,000</div>");
markers.push(marker);
marker = new nokia.maps.map.StandardMarker(new nokia.maps.geo.Coordinate(38.5188500, 27.1287200));
addInfoBubble( infoBubbles, marker, "<div ><a href='http://www.liverpoolfc.tv' >Liverpool</a></div><div >Anfield<br>Capacity: 45,362</div>");
markers.push(marker);
map.objects.addAll(markers);
}
</script>
</body>
</html>