How can I overlay 3D model over google or iOS maps?

I have a 3D model for building in KML format and i want to import it over google or apple maps to get the user location and find POI.

I have find that google maps v2 [1]: support 3d objects.


Although this is a very late answer, I think below sources (for Android/iOS implementations) should help at least for future reference because I don't see much detailed information right now about KML/KMZ files and their structures;

*If the 3D model is just a 3D image created by photo editing tools or if creating 3D image meets with needs, then below solutions can be used to load them via Google Maps or Apple Maps (MapKit) SDKs.

Google Maps

-- For Android

Below code is taken from “”. I am sharing it only to visualize the implementation.


import org.xmlpull.v1.XmlPullParserException;

import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;


public class KmlDemoActivity extends BaseDemoActivity {

    private GoogleMap mMap;

    protected int getLayoutId() {
        return R.layout.kml_demo;

    public void startDemo () {
        try {
            mMap = getMap();
        } catch (Exception e) {
            Log.e("Exception caught", e.toString());

    private void retrieveFileFromResource() {
        try {
            KmlLayer kmlLayer = new KmlLayer(mMap, R.raw.campus, getApplicationContext());
        } catch (IOException e) {
        } catch (XmlPullParserException e) {

    private void retrieveFileFromUrl() {
        new DownloadKmlFile(getString(R.string.kml_url)).execute();

    private void moveCameraToKml(KmlLayer kmlLayer) {
        //Retrieve the first container in the KML layer
        KmlContainer container = kmlLayer.getContainers().iterator().next();
        //Retrieve a nested container within the first container
        container = container.getContainers().iterator().next();
        //Retrieve the first placemark in the nested container
        KmlPlacemark placemark = container.getPlacemarks().iterator().next();
        //Retrieve a polygon object in a placemark
        KmlPolygon polygon = (KmlPolygon) placemark.getGeometry();
        //Create LatLngBounds of the outer coordinates of the polygon
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (LatLng latLng : polygon.getOuterBoundaryCoordinates()) {

        int width = getResources().getDisplayMetrics().widthPixels;
        int height = getResources().getDisplayMetrics().heightPixels;
        getMap().moveCamera(CameraUpdateFactory.newLatLngBounds(, width, height, 1));

    private class DownloadKmlFile extends AsyncTask<String, Void, byte[]> {
        private final String mUrl;

        public DownloadKmlFile(String url) {
            mUrl = url;

        protected byte[] doInBackground(String... params) {
            try {
                InputStream is =  new URL(mUrl).openStream();
                ByteArrayOutputStream buffer = new ByteArrayOutputStream();
                int nRead;
                byte[] data = new byte[16384];
                while ((nRead =, 0, data.length)) != -1) {
                    buffer.write(data, 0, nRead);
                return buffer.toByteArray();
            } catch (IOException e) {
            return null;

        protected void onPostExecute(byte[] byteArr) {
            try {
                KmlLayer kmlLayer = new KmlLayer(mMap, new ByteArrayInputStream(byteArr),
                kmlLayer.setOnFeatureClickListener(new KmlLayer.OnFeatureClickListener() {
                    public void onFeatureClick(Feature feature) {
                                "Feature clicked: " + feature.getId(),
            } catch (XmlPullParserException e) {
            } catch (IOException e) {

-- For iOS Below code is taken from the above url. Again, I am sharing it only to visualize the implementation.

Swift sample

/** Assume that <Google-Maps-iOS-Utils/GMUGeometryRenderer.h> and
    <Google-Maps-iOS-Utils/GMUKMLParser.h> are in the bridging-header file.
let path = Bundle.main.path(forResource: "KML_Sample", ofType: "kml")
let url = URL(fileURLWithPath: path!)
kmlParser = GMUKMLParser(url: url)

renderer = GMUGeometryRenderer(map: mapView,
                               geometries: kmlParser.placemarks,
                               styles: kmlParser.styles)


Objective-C sample

#import "GMUKMLParser.h"
#import "GMUGeometryRenderer.h"
NSString *path = [[NSBundle mainBundle] pathForResource:@"KML_Sample" ofType:@"kml"];
NSURL *url = [NSURL fileURLWithPath:path];
GMUKMLParser *parser = [[GMUKMLParser alloc] initWithURL:url];
[parser parse];
GMUGeometryRenderer *renderer = [[GMUGeometryRenderer alloc] initWithMap:_mapView
[renderer render];

Apple Maps (iOS MapKit)

But for Apple Maps, I see that a parser needed like below ones to turn KML data structures into drawing code;

Or below KMLViewer implementations can be used; (Based on NSXMLParser) (Also contains Swift versions)

**Otherwise, if 3D model is really a 3D model that is created by <Model> tag (3D models are described in COLLADA file (.dae) and referenced by <link> tag) See below XML format from “”;

<Model id="ID">
  <!-- specific to Model -->
      <!-- kml:altitudeModeEnum: clampToGround,relativeToGround,or absolute -->
      <!-- or, substitute gx:altitudeMode: clampToSeaFloor, relativeToSeaFloor -->
    <longitude></longitude> <!-- kml:angle180 -->
    <latitude></latitude>   <!-- kml:angle90 -->
    <altitude>0</altitude>  <!-- double -->
    <heading>0</heading>    <!-- kml:angle360 -->
    <tilt>0</tilt>          <!-- kml:anglepos180 -->
    <roll>0</roll>          <!-- kml:angle180 -->
    <x>1</x>                <!-- double -->
    <y>1</y>                <!-- double -->
    <z>1</z>                <!-- double -->
      <targetHref>...</targetHref>   <!-- anyURI -->
      <sourceHref>...</sourceHref>   <!-- anyURI -->

Above picture is taken from As shown there, Google Maps seems to not support 3D models with tags. Google Earth seems to support 3D models but of course it is not suitable for our case. In addition to this, I didn't see any official support from iOS MapKit.

So, below solutions may work for real 3D models;

I've come across with the OSMBuildings based on OpenStreetMap while I was doing research. It is a Javascript implementation but it may also be used on mobile environments by using for example Leaflet JS library. (KML file should be converted to GeoJSON by “leaflet-omnivore” plugin for this purpose and it seems it is supporting 3D models)

Lastly, I've found a mapping platform called MapBox that accepts KML (by converting it to GeoJSON again). This option is a paid option but I think there is enough limit for small, personal apps to use it for free (50,000 map views/mo). (Again OpenStreetMap-based platform and it seems it is supporting 3D models)

Although there may be other libraries or platforms to use KMLs/KMZs, I think these are best suitable ones for mobile experience (for both iOS and Android).

Last small note: KMZ is actually a compressed package that contains KML, textures and various resources in it.

Although this is an old question. I think Apple has an example project in the documentation.

Need Your Help

jQuery function after .append


How to call a function after jQuery .append is completely done?