Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Showing maps using an address

This may sound like a simple problem but I have an application which pulls data from a database and clicking on an address calls appcelerators mapview function and show a map (which all works fine).

However, I don't have the long and lats for any addresses in my database and looking at the API doc it just refers to 'location' and 'region' in the form of long and lats, I don't want to send this because I don't have that information.

Is there a way to show a map passing a full address (including postcode/zip and country) and not just long and lats?

Regards, Scott.

— asked October 28th 2010 by Scott Smith
  • latitude
  • longitude
  • maps
  • mapview
  • postcode
  • zipcode
0 Comments

3 Answers

  • Try looking at this site. http://developer.yahoo.com/geo/placefinder/

    — answered October 28th 2010 by John McKnight
    permalink
    0 Comments
  • try something like this:

    var addr = 'ZIP, City, Country';
    
    Titanium.Geolocation.forwardGeocoder(addr,function(evt) {
        var objLocationAnnotation = Titanium.Map.createAnnotation({
            latitude: evt.latitude,
            longitude: evt.longitude,
            image: 'img/icon-marker-map.png'
        });
        objMapView.addAnnotation(objLocationAnnotation);
    });
    
    — answered October 28th 2010 by Stefan Schleich
    permalink
    2 Comments
    • Hi, Thanks for the response. I have tried to implement what you have suggested to some sample code but get a blue screen when the map screen loads. I presume I am missing something important to get the correct map to display. I have added my code below:

      var mapview = Titanium.Map.createView({
                  mapType: Titanium.Map.STANDARD_TYPE,
                  animate:true,
                  regionFit:true
              });
      
              var addr = 'SW1A 2AA, London, United Kingdom';
      
              Titanium.Geolocation.forwardGeocoder(addr,function(evt) {
                  var objLocationAnnotation = Titanium.Map.createAnnotation({
                      latitude: evt.latitude,
                      longitude: evt.longitude,
                      image: 'appcelerator_small.png'
                  });
                  mapview.addAnnotation(objLocationAnnotation);
              });
      
              third.add(mapview);
      

      My main window is called 'third' for testing purposes and also I am using the simulator as I am just displaying a map, not doing any GPD type stuff (does this matter?), Scott.

      — commented October 28th 2010 by Scott Smith
    • GPD = GPS (Typo!)

      — commented October 28th 2010 by Scott Smith
  • Yet another update:

    Try running the code on the phone! The lookup of addresses just doesn't seem to work properly in my simulator - on my phone it works like a charm! :-)


    Update: It seems I was wrong; it makes no difference which order I put the code. The problem for me was just, that sometimes the address does not resolve to a position.


    I had the same problem - the map would just show a blue screen - some water somewhere.

    What worked for me, was to add the map to my window, before I set the position.

    — answered November 25th 2010 by John Doktor
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.