473,386 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to use the ajax to pin more point

hi i am doing a project now i going to use ajax to retrieve coordinate from the json in html and pin the coordinate onto a point on the map using javascript but the problem is i am only able to use one point on the map can tell me what to add in ? or how should i change it with? p.s it will be nice if u can change the code from the below and show me how

Expand|Select|Wrap|Line Numbers
  1. function addSymbol() {
  2. if (omap.map.getLayer("symbolLayer") == null) {
  3. omap.map.addLayer(gLayer);
  4. omap.map.infoWindow.resize(760, 425);
  5. }
  6. gLayer.clear();
  7. function ajaxRequest(){
  8. var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] 
  9. if (window.ActiveXObject){ 
  10. for (var i=0; i<activexmodes.length; i++){
  11. try{
  12. return new ActiveXObject(activexmodes[i])
  13. }catch(e){ }
  14. }
  15. }
  16. else if (window.XMLHttpRequest) 
  17. return new XMLHttpRequest()
  18. else
  19. return false
  20. }
  21.  
  22. var mygetrequest=new ajaxRequest()
  23. mygetrequest.onreadystatechange=function(){
  24. if (mygetrequest.readyState==4){
  25. if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
  26. var books=eval("("+mygetrequest.responseText+")") //retrieve result as an JavaScript object
  27. var rssentries=books.places
  28. var output = ""
  29. var xCoo = ""
  30. var yCoo= ""
  31. for (var i=0; i<rssentries.length; i++){
  32. output += rssentries[i].name
  33. xCoo += rssentries[i].x_coordinate
  34. yCoo += rssentries[i].y_coordinate
  35. }
  36. document.getElementById("result").innerHTML = output
  37. var stX = xCoo
  38. var stY = yCoo
  39. var pt = new esri.geometry.Point(stX, stY, omap.map.spatialReference);
  40. var attr = { "PlaceName": " Singapore", "PlaceAddr": "addr" };
  41. var strImage = "http://www.rw-designer.com/i/download48b.png";
  42. var symbol = new esri.symbol.PictureMarkerSymbol(strImage, 25, 25);
  43. var infoTemplate = new esri.InfoTemplate();
  44. infoTemplate.setContent();
  45. var graphic = new esri.Graphic(pt, symbol, attr, infoTemplate);
  46. gLayer.add(graphic);
  47. }
  48. else{
  49. alert("An error has occured making the request")
  50. }
  51. }
  52. }
  53. mygetrequest.open("GET", "HTMLPage3.htm", true)
  54. mygetrequest.send(null);
  55. }
  56. dojo.addOnLoad(addSymbol); 
  57.  
  58.  
this is htmlpage3
Expand|Select|Wrap|Line Numbers
  1. { "places": [
  2. {
  3. "id": "1",
  4. "name": "Chinese Swimming Club",
  5. "x_coordinate": "35484.66533355533",
  6. "y_coordinate": "31293.823929446196",
  7. "icon": "C:/Users/L33508/Desktop/Peranakan@SG/Peranakan@SG/images/museum.png"
  8. },
  9. {
  10. "id": "2",
  11. "name": "Joo Chiat Police Station",
  12. "x_coordinate": "35951.524906914485",
  13. "y_coordinate": "31862.739419191174",
  14. "icon": "C:/Users/L33508/Desktop/Peranakan@SG/Peranakan@SG/images/museum.png"
  15. },
  16. {
  17. "id": "3",
  18. "name": "Saint Patrick Secondary School",
  19. "x_coordinate": "55555.5555",
  20. "y_coordinate": "55555.5555",
  21. "icon": "C:/Users/L33508/Desktop/Peranakan@SG/Peranakan@SG/images/museum.png"
  22. },
  23. {
  24. "id": "4",
  25. "name": "Red House",
  26. "x_coordinate": "66666.6666",
  27. "y_coordinate": "66666.6666",
  28. "icon": "C:/Users/L33508/Desktop/Peranakan@SG/Peranakan@SG/images/museum.png"
  29. },
  30. {
  31. "id": "5",
  32. "name": "Amber Road Sea View",
  33. "x_coordinate": "35580.593252799175",
  34. "y_coordinate": "31579.825950310897",
  35. "icon": "C:/Users/L33508/Desktop/Peranakan@SG/Peranakan@SG/images/museum.png"
  36. }
  37. ]
  38. }
  39.  
  40.  
May 21 '11 #1
0 1028

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Yarco | last post by:
I want to use "Ajax" to create my web for hobby. But i don't know whether "Ajax" is mature... And what about with php? Someone have experience on it? ....
4
by: bobzimuta | last post by:
I'm creating a simple AJAX library. It's an object that will return an array containing the response text or xml. I'm trying to find a way to assign the response as a property of the object, but...
10
by: Bugsy | last post by:
hi fellows pro,,,,, i want some details regarding AJAX. can anyone help me in that .... reply me with some good articles as well as tutorials in (.net)
21
by: javainfo | last post by:
How can i refresh IFRAME and load data through AJAX?
7
by: Thirsty Traveler | last post by:
Peter Bromberg has an interesting article eggheadcafe discussing AJAX libraries. He prefers ANTHEM.NET over AJAX.NET because it doesn't break the stateful page model. Our developers are currently...
5
by: darrel | last post by:
I've been playing with prototype.js and scriptaculous to create some nice drag-and-drop interaction on my applications GUI. That's working well. Now I want to take the next step and start passing...
5
by: matt.delvecchio | last post by:
hello, im working on my first production AJAX project, and im noticing something weird. when my clientside events fire (user clicks on various product rows), i make an xmlhttp call. in this...
31
by: Tony | last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET distribution - I'm pretty concerned about this. Does anyone know if this is the same "prototype.js" that is not well-liked...
10
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
controlsPlease could some of you here post some of your live examples of AJAX (esp drag panels, collapsable panels, and popup menu.) (It's one thing to talk about how great something is, but it's...
4
by: Nuno | last post by:
Hi, Maybe this question alreay was asked, but now, i'm asking today... today each ajax framework is the best one to start (open source of course). I already see so much (ASP.NET AJAX, GWT,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.