IntelliJ Java IDE
The moose likes HTML, CSS and JavaScript and the fly likes create a marker of a map Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "create a marker of a map" Watch "create a marker of a map" New topic
Author

create a marker of a map

mounir mejri
Greenhorn

Joined: Jan 30, 2012
Posts: 1
shareef hiasat wrote:Thank you its just what i needed

hi
i have a problem with my code , In fact I want to create a marker of a map as an image that indicates the point of departure and arrival the problem is that the image is not displayed
the code here:
function createMarker(e) {
if (window.event) var e = window.event;




var scroll = findScroll();
var zoneEnCours = zoneOfPoint(map_coord);
alert(map_coord.x);

if (!zoneEnCours) return;

if (!depart.image) {
depart.image = new Image();
depart.image.src = "img/intermap/from.png";
alert(depart.image.src);
document.body.appendChild(depart.image);
depart.image.style.position = "absolute";
depart.image.style.left = (e.clientX - 5 + scroll.x) + "px";
depart.image.style.top = (e.clientY - 5 + scroll.y) + "px";
depart.zone = zoneEnCours;
depart.image.onmousemove = function (e) {
zoom(e);
};
depart.image.onmouseover = function (e) {
this.className = "markeron";
};
depart.image.onmouseout = function (e) {

this.className = "marker";
};
depart.image.onclick = function (e) {

createMarker(e);
};
} else if (!arrivee.image) {
arrivee.image = new Image();
arrivee.image.src = "img/intermap/arrow.gif";
document.body.appendChild(arrivee.image);
arrivee.image.style.position = "absolute";
arrivee.image.style.left = (e.clientX - 6 + scroll.x) + "px";
arrivee.image.style.top = (e.clientY - 10 + scroll.y) + "px";
arrivee.zone = zoneEnCours;
arrivee.image.onmouseover = function (e) {
this.className = "markeron";
};
arrivee.image.onmouseout = function (e) {
this.className = "marker";
};
getelem("formulaire").style.display = "";
if (depart.zone.id == arrivee.zone.id) bonsZone = 1;
else if (depart.zone.limitrophes.indexOf(arrivee.zone.id) > -1) bonsZone = 1;
else bonsZone = 3;
var unite = "bon";
if (bonsZone > 1) unite = "bons";
getelem('bonbase').innerHTML = bonsZone + " " + unite;
total();
}
}

and here is the html part
<img id="imgMini" class="carte" src="img/intermap/idfp.png" alt="carte de l'IDF" onMouseMove="zoom(event)" onClick="createMarker(event)" onDblClick="clearMap()">
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

Welcome to the Ranch.

You had posted this as a reply to another topic, so I moved it to its own topic.

Also, please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.

Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
 
subject: create a marker of a map
 
Threads others viewed
Events in JSP are not supported in Mozilla
Regarding Single log in
Div popup
Browser coords in FF not working but working in IE
Displaying a DIV wherever the mouse location is
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com