Maps Example

edited March 2012 in Enyo 2
Hi,

I m newbie to JavaScript and HTML5. I am using maps example to make an app (currently live on iphone).
I want to do is show pinDrops on bing map using API i made in PHP which returns data of latitude/longitude/title/detail in JSON format only.

My question 1 : what is the best approach to achieve this suppose if data return from my API is like this:
[
    {
       
        "beepid": "1989",
        "beep": "California ",
        "Lat": "37.723508",
        "long": "-122.163363",
        "beepdescription": "San Leandro Wells",
        
    },
    {
        
        "beepid": "1992",
        "beep": "Spot de raquette",
        "Lat": "45.959112",
        "long": "-74.347268",
        "beepdescription": "Site de raquette de classe mondial",
       
    }
]
Where beep/beepdescription is same as title/detail

Mockdata.js contains dummy data in similar format also.

My question 2: how to do login form as a popup when someone clicks on a button. authenticates user on basis of reply from the server which is also in json format. Example

If credentials r valid
[ { status: success } ]

If not then
[ { status: not success } ]


I have tried blogging on sites of javascript/html blogs but many people aren't aware of this as it is new.


Any help is appreciated !
Thnx

Comments

  • That data isn't valid JSON -- it has trailing commas. Make sure any output returned by your server can pass the test at http://www.jsonlint.com/ or you'll have problems when parsers understanding it.
  • edited March 2012
    Sorry,I deleted some of the keys and value which wr not of use in this.
    Actual Data is validated from jsonlint.
    [
        {
           
            "beepid": "1989",
            "beep": "California ",
            "Lat": "37.723508",
            "long": "-122.163363",
            "beepdescription": "San Leandro Wells"
            
        },
        {
            
            "beepid": "1992",
            "beep": "Spot de raquette",
            "Lat": "45.959112",
            "long": "-74.347268",
            "beepdescription": "Site de raquette de classe mondial"
           
        }
    ]
  • OK, with that cleared up, it looks like you need to figure out the Bing Maps API to see how to handle pins. Details are at https://www.microsoft.com/maps/developers/web.aspx -- the Enyo wrapper is just a container for that code.

    As for the login form, you'll likely need to use an enyo.Popup kind to show some controls, map a button's onclick event to a login handler and have that use an enyo.Ajax object to make a XHR call to your service.
  • edited March 2012
    Hi,

    Does enyo have and in-built functions to post a request to a url and process the returned JSON response.. ?

    I am trying to use name: "enyo.JsonpRequest" but cant understand how to place url.

    Thnx
  • enyo.JsonpRequest is used for web APIs that are accessed by adding a `` tag; it's mainly useful for cross-domain requests.

    For a normal AJAX call, you'd create an instance of the enyo.Ajax object.
  • edited March 2012
    For standard requests:
    new enyo.Ajax({url: "data.json"}).go().respond(function(inSender, inResponse) {
      // inResponse contains the object parsed from data.json
    });
  • edited March 2012
    is there something like :
    $.get("someurl.com", function(data) {
    		var reurnedData = data;
    		var json = $.parseJSON(reurnedData);
    		console.log(typeof(json));
    		
    		for (var i=0;i
    in enyo built-in function as above one is giving me Access-Control-Allow-Origin error.
  • That's coming from the browser and is a fundamental technology issue. To make cross-domain requests, you either have to use JSONP or have a recent browser and all the cross-browser control files set up on the different servers.
Sign In or Register to comment.