Skip to content
Browse files

changes for default error messages

  • Loading branch information...
1 parent e20654a commit 19212c5938fc23dc558d6f48feb7e1e62f2142c9 @bhagwat bhagwat committed
Showing with 29 additions and 7 deletions.
  1. +13 −1 grails-app/taglib/org/grails/plugin/googlemap/taglib/MapTagLib.groovy
  2. +16 −6 web-app/js/map.init.js
View
14 grails-app/taglib/org/grails/plugin/googlemap/taglib/MapTagLib.groovy
@@ -46,6 +46,18 @@ class MapTagLib {
writer << resource(dir: pluginContextPath, file: 'css/jquery.autocomplete.css')
writer.println '" />'
}
+
+ Map errorMessages=attrs.remove('errorMessages')
+ if(errorMessages){
+ writer.println '<script type="text/javascript">'
+ writer.println 'var error_messages_json={};'
+ errorMessages.collect{errorKey, message->
+ writer.println "error_messages_json['${errorKey}']='${message.encodeAsJavaScript()}';"
+ }
+ writer.println 'googleMapManager.setErrorMessages(error_messages_json);'
+
+ writer.println '</script>'
+ }
}
def map = {attrs ->
@@ -81,7 +93,7 @@ class MapTagLib {
eventsScript += getEventHandlerJavaScript(googleMapObject, eventHandler)
}
- List mapSettingsList = attrs.collect { k, v -> "$k:$v"}
+ List mapSettingsList = []//attrs.collect { k, v -> "$k:$v"}
mapSettingsList.addAll(["mapTypeId:${mapTypeId}", "zoom:${zoom}"])
String mapSettings = mapSettingsList.join(", ")
View
22 web-app/js/map.init.js
@@ -77,11 +77,12 @@ function GoogleMapManager() {
streetViewService = null;
messages = {
- noGeoCodeResult:"No result found",
- geoCodingFailed:"GeoCoding failed",
+ noResultError:"No result found",
+ geoCoderError:"GeoCoding failed",
noStreetViewAvailable:"No street view available for this location",
getDirectionFailed:"Failed to get direction"
};
+
function createMarker(map, position) {
return new google.maps.Marker({map: map, position: position, draggable:true});
}
@@ -209,7 +210,7 @@ function GoogleMapManager() {
marker.setPosition(results[0].geometry.location);
map.setCenter(results[0].geometry.location);
} else {
- alert(messages["noGeoCodeResult"]);
+ alert(messages["noResultError"]);
}
} else {
alert(messages["geoCodingFailed"]);
@@ -233,7 +234,7 @@ function GoogleMapManager() {
showStreetView: function (address, map, settings, successHandler, errorHandlerCallback, caller) {
var radius=settings.radius||100; // look into circle of radius x metres
var povSettings = {};
- povSettings.heading = settings.heading || 0;
+ povSettings.heading = settings.heading;
povSettings.pitch = settings.pitch || 0;
povSettings.zoom = settings.zoom || 1;
if (settings.panoramaId) {
@@ -247,7 +248,9 @@ function GoogleMapManager() {
if (successHandler) {
successHandler(data, status, caller)
}else{
- povSettings.heading=computeAngle(mapConfiguration[map].homeMarker.getPosition(), data.location.latLng) || povSettings.heading;
+ if(povSettings.heading){
+ povSettings.heading=computeAngle(mapConfiguration[map].homeMarker.getPosition(), data.location.latLng) || povSettings.heading;
+ }
showStreetViewForConfiguration(map, data.location.pano, povSettings);
}
} else {
@@ -376,6 +379,13 @@ function GoogleMapManager() {
}
return infoWindow;
},
+
+ setErrorMessages:function(errorMessagesMap){
+ jQuery.each(errorMessagesMap, function(key, value){
+ messages[key]=value;
+ });
+ },
+
codeLatLng: function (addressOrLatLng, callBackFunction) {
var addressLookup = getGeoCoder();
if (addressLookup) {
@@ -383,7 +393,7 @@ function GoogleMapManager() {
if (status == google.maps.GeocoderStatus.OK) {
callBackFunction(results);
} else {
- alert(messages["geoCodingFailed"]);
+ alert(messages["geoCoderError"]);
}
});
}

0 comments on commit 19212c5

Please sign in to comment.
Something went wrong with that request. Please try again.