Created
August 25, 2014 08:23
-
-
Save ikiw/775a2a438571ba4e00d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sap.ui.core.Control.extend("ref.google.Map", { | |
metadata : { | |
properties : { | |
address : "string" | |
} | |
}, | |
init: function(){ | |
this._html = new sap.ui.core.HTML({content:"<div style='height:100%;width:100%;' id='" + this.getId()+"-map'></div>"}); | |
}, | |
renderer : function(oRm, oControl) { | |
oRm.write("<div style='height:400px;width:400px;margin:20px;' "); | |
oRm.writeControlData(oControl); | |
oRm.write(">"); | |
oRm.renderControl(oControl._html); | |
oRm.write("</div>"); | |
}, | |
onAfterRendering : function() { | |
var options = { | |
zoom:12, | |
mapTypeId: "roadmap" | |
}; | |
var _map = new google.maps.Map(jQuery.sap.domById(this.getId()+"-map"),options); | |
var geocoder = new google.maps.Geocoder(); | |
geocoder.geocode( { 'address': this.getAddress()}, function(results, status) { | |
if (status == google.maps.GeocoderStatus.OK) { | |
_map.setCenter(results[0].geometry.location); | |
var marker = new google.maps.Marker({ | |
map: _map, | |
position: results[0].geometry.location | |
}); | |
} else { | |
alert('Geocode was not successful for the following reason: ' + status); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment