Hi,
I was recently working on a project where i need to fetch multiple locations used google maps API. I searched a lot and tried many examples but was'nt able to find any appropriate, finally i gone through the documentation of google maps API. I found the solution
Below is the list where i stored all my addresses
var addresses =new Array();
addresses[] = '';
Here's my onload function
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(10, -180), 13);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
geocoder = new GClientGeocoder();
GEvent.addListener(map, 'click', function(overlay, point) {
if (point) {
//document.getElementById("show_x").innerHTML = point.x;
// document.getElementById("show_y").innerHTML = point.y;
}
});
GEvent.addListener(map, 'zoomend',
function(oldZoomLevel, newZoomLevel) {
//document.getElementById("zoom_old").innerHTML = oldZoomLevel;
//document.getElementById("zoom_new").innerHTML = newZoomLevel;
});
}
showAddress();
}
Here's my show address function
function showAddress() {
//alert("address : " + addresses);
convertToLatLng();
}
Here's my convertToLatLng, this function is the core function i used for
var points = [];
function convertToLatLng() {
if (points.length >= addresses.length) {
showPoints();
} else {
geocode(addresses[points.length]);
}
}
My geocode function
function geocode(address) {
//alert(address);
geocoder.getLatLng(
address,
function(point) {
if(!point)
{
}
else
{
points.push(point);
window.setTimeout(convertToLatLng, 300);
map.setCenter(point, 13);
//var marker = new GMarker(point);
var letters=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P", "Q","R","S","T","U","V","W","X","Y","Z"];
var marker=createMarker(point, letters[points.length-1]);
map.addOverlay(marker);
//marker.openInfoWindowHtml(address + "
Long: " + point.x + "
Lati: " + point.y);
//document.getElementById("show_x").innerHTML = point.x;
//document.getElementById("show_y").innerHTML = point.y;
//document.getElementById("zoom_new").innerHTML = 14;
}
}
);
}
My show points function, this function displays points for each location fetched from the database
function showPoints() {
for (i in points) {
var lat_lng = points[i];
if (lat_lng) {
var marker=createMarker(points[i], letters[i]);
map.addOverlay(marker);
//map.addOverlay(new GMarker(lat_lng));
}
}
}
I tweaked a bit and created alphabetical markers for the map as below
function createMarker(point, letter) {
// use a custom icon with letter A - Z
var letter = letter;
var myIcon = new GIcon(G_DEFAULT_ICON, "http://www.google.com/mapfiles/marker" + letter + ".png");
myIcon.printImage = "http://maps.google.com/mapfiles/marker"+letter+"ie.gif";
myIcon.mozPrintImage = "http://maps.google.com/mapfiles/marker"+letter+"ff.gif";
var CallSign = CallSign;
var marker = new GMarker(point, {icon:myIcon});
//GEvent.addListener(marker, "click", function()
//{
//
//// save the info we need to use later for the side_bar
//gmarkers.push(marker)
//// add a line to the side_bar html
//
//
//
//});
return marker;
}
This is how i did to display multiple locations on the map.
Cheers!!!
Ujjwal
Friday, March 26, 2010
Array List Sorting Issue
Hi,
Recently, i was coding for an application and came across a problem where i need to sort an ArrayList in an alphabetical order. However, that sounded quite easy as because sorting can easy with single arraylist. But, i was in a situation where i had two different ArrayLists with multiple attributes. So, what i did is that i kept a delimeter to distinct all my 3 values and then i added them into a temporary list.
for(int j=0;j
{
myBean=(MyBean)myList.get(j);
tempList.add(myBean.getOne() + "*" + myBean.getTwo() + "*" + myBean.getThree());
}
then i used collection's sort method to sort them up in an alphabetical form.
Collections.sort(tempList,new MyComparator());
I used inner class called Mycomparator to compare.
class MyComparator implements Comparator {
public int compare(Object o1,
Object o2) {
String s1 = o1.toString().toUpperCase();
String s2 = o2.toString().toUpperCase();
int counter = 0;
for (counter=0;counter
!Character.isDigit(s1.charAt(counter));counter++);
String temp1 = s1.substring(counter);
s1 = s1.substring(0,counter);
for (counter=0;counter
!Character.isDigit(s2.charAt(counter));counter++);
String temp2 = s2.substring(counter);
s2 = s2.substring(0,counter);
int max = (temp1.length() > temp2.length()) ? temp1.length() : temp2.length();
char[] pad = new char[max-temp1.length()];
Arrays.fill(pad,(char)48);
temp1 = String.valueOf(pad) + temp1;
pad = new char[max-temp2.length()];
Arrays.fill(pad,(char)48);
temp2 = String.valueOf(pad) + temp2;
s1 = s1 + temp1;
s2 = s2 + temp2;
return(s1.compareTo(s2));
}
public boolean equals(Object o1,
Object o2) {
String s1 = o1.toString();
String s2 = o2.toString();
return(s1.equals(s2));
}
}
And finally,. the problem got resolved, i got my list ordered in alphabetical form.
Thursday, February 25, 2010
Problems installing Myeclipse 8.0
Hi,
Today, i was installing Myeclipse 8.0, i faced some issues while installing that. It showed below errors.
Well, later on i discovered that pulse explorer that is a part of my eclipse tried to download some updated from internet, since my machine was under a firewall it failed and showed abover errors. So, then as a solution for that, i downloaded and installed pulse explorer seperately and then ran my myeclipse setup again and this time, i got it successfully installed.
Regards,
Ujjwal Soni
.
Today, i was installing Myeclipse 8.0, i faced some issues while installing that. It showed below errors.
Pulse has been unable to create a plan for Myeclipse 8.0 latest. Pleace check details below etc etc...
Please provide a non pulse installation option.
Details
This profile can not be resolved because required software could not be located.
Could not locate installable unit: com.genuitec.myeclipse.matisse.feature.group [7.1.0,7.5.0)
Could not locate installable unit: com.genuitec.myeclipse.enterprise.workbench.feature.group [7.1.0,7.5.0)
Could not locate installable unit: com.genuitec.myeclipse.tapestry.feature.group [7.1.0,7.5.0)
Could not locate installable unit: com.genuitec.myeclipse.reports.feature.group [7.1.0,7.5.0)
Could not locate installable unit: com.genuitec.myeclipse.icefaces.feature.feature.group [7.1.0,7.5.0)
Checked update site http://download.eclipse.org/eclipse/updates/3.4 and found 1811 installable units.
Checked update site http://download.eclipse.org/releases/ganymede and found 3799 installable units.
Checked update site http://downloads2.poweredbypulse.com/downloads/products/pulse/client and found 116 installable units.
Checked update site http://downloads2.poweredbypulse.com/downloads/products/pulse/eclipse34 and found 1 installable units.
Checked update site http://downloads2.poweredbypulse.com/downloads/products/pulse/ganymede and found 104 installable units.
Checked update site http://downloads3.myeclipseide.com/downloads/products/eworkbench/ganymede-latest and found 816 installable units.
Checked update site http://downloads3.myeclipseide.com/downloads/products/eworkbench/ganymede-latest/supporting and found 20 installable units.
Checked update site http://downloads3.myeclipseide.com/downloads/products/eworkbench/jdks and found 6 installable units.
Checked update site http://www.poweredbypulse.com/installer/eclipse-base and found 2 installable units.
Checked update site http://www.poweredbypulse.com/pulse/download/live and found 1 installable units.
Well, later on i discovered that pulse explorer that is a part of my eclipse tried to download some updated from internet, since my machine was under a firewall it failed and showed abover errors. So, then as a solution for that, i downloaded and installed pulse explorer seperately and then ran my myeclipse setup again and this time, i got it successfully installed.
Regards,
Ujjwal Soni
.
Sunday, January 31, 2010
10 Commandments for Java Developers
1. Add comments to your code
2. Do not complicate things - Means don’t come up with complicated solution for simplest problems
3. Keep in Mind "Less is more" is not always better - Means when necessary write all required code
4. No hard coding please.
5. Do not invent your own frameworks. - use available superb frameworks like Struts,JSF or Spring
6. Say no to Print lines and String Concatenations
7. Pay attention to the GUI - Look and Feel always matters
8. Always Prepare Document Requirements
9. Unit-test. Unit-test. Unit-test - Always do unit test
10. Remember quality, not quantity.
2. Do not complicate things - Means don’t come up with complicated solution for simplest problems
3. Keep in Mind "Less is more" is not always better - Means when necessary write all required code
4. No hard coding please.
5. Do not invent your own frameworks. - use available superb frameworks like Struts,JSF or Spring
6. Say no to Print lines and String Concatenations
7. Pay attention to the GUI - Look and Feel always matters
8. Always Prepare Document Requirements
9. Unit-test. Unit-test. Unit-test - Always do unit test
10. Remember quality, not quantity.
Tuesday, January 26, 2010
Framework for cloud computing using java
Hi,
Recently, i was searching for java based framework suitable for cloud computing and i suddenly came across grid gain.
GridGain is an ideal platform for Native Cloud Applications. GridGain provides developers with powerful and elegant technology to develop and run applications on private or public clouds.
GridGain is developed in Java and for Java developers and it is a natural extension of the latest Java development methodologies including annotations, integration of Spring and AOP-based grid-enabling.
For more details http://www.gridgain.com/
Recently, i was searching for java based framework suitable for cloud computing and i suddenly came across grid gain.
GridGain is an ideal platform for Native Cloud Applications. GridGain provides developers with powerful and elegant technology to develop and run applications on private or public clouds.
GridGain is developed in Java and for Java developers and it is a natural extension of the latest Java development methodologies including annotations, integration of Spring and AOP-based grid-enabling.
For more details http://www.gridgain.com/
Friday, January 22, 2010
Getting square block characters when carriage return used in MS Excel 2003
Hi,
Recently i was facing a strange issue with JXL API for excel sheet generation using JAVA, the data entry screen was fine but when i was generating reports, i got some strange characters at each carriage return. This issue only happened in MS Excel 2003, this worked fine in other office versions.
Actually this issue only appeared in some European countries, worked fine in Asia.
So, i tried replaceAll method to replace this character with blank spaces like this ::
reportValue.replaceAll("[\\r\\n]", "");
This worked fine but it removed all my carriage returns too..
So, i tried below code which removed that square block character and restored my keystrokes.
reportValue..replace('\r',' ').replace('\'',' ');
This worked absolutely fine in All office versions and all countries for both europe and asia.
Cheers,
Ujjwal Soni
Recently i was facing a strange issue with JXL API for excel sheet generation using JAVA, the data entry screen was fine but when i was generating reports, i got some strange characters at each carriage return. This issue only happened in MS Excel 2003, this worked fine in other office versions.
Actually this issue only appeared in some European countries, worked fine in Asia.
So, i tried replaceAll method to replace this character with blank spaces like this ::
reportValue.replaceAll("[\\r\\n]", "");
This worked fine but it removed all my carriage returns too..
So, i tried below code which removed that square block character and restored my keystrokes.
reportValue..replace('\r',' ').replace('\'',' ');
This worked absolutely fine in All office versions and all countries for both europe and asia.
Cheers,
Ujjwal Soni
Monday, January 18, 2010
Open Source Caching Solutions for Java
Hi,
Here's some open source caching solutions for Java ::
http://java-source.net/open-source/cache-solutions
Here's some open source caching solutions for Java ::
http://java-source.net/open-source/cache-solutions
Subscribe to:
Posts (Atom)