ChrisMcCabe


Is it possible to get places returned from the Find or FindNearby methods without it automatically adding pushpins to the map I can easily add the pushpins myself, and use a custom pushpin if I want, add custom information to the info box, and keep track of them better, but the way it works prevents me from doing any of that. I may not want certain items on the map at all.



Re: Is it possible to find places without adding pushpins?

Caleb T - MSFT


Quick answer: Not in VE, at least not right now.

You can do this with MWS, and the product team knows this is a very common request for VE.






Re: Is it possible to find places without adding pushpins?

ChrisMcCabe

I found a simple hack/workaround that works. The AddPushpin method of the VEMap control can be temporarily overridden to ignore the adding of the pushpin, then the pushpins can be added in the callback method.

Here is an example:

var saveAP = null;

function findPlaces(what, where)
{
// save the AddPushpin method
saveAP = vemap.AddPushpin;

// change it to do nothing
vemap.AddPushpin = function() {};

// do the find
vemap.Find(what, where, 1, foundPlaces);
}

function foundPlaces(results)
{
// restore the AddPushpin method
vemap.AddPushpin = saveAP;
// process results and add pushpins manually ...
}





Re: Is it possible to find places without adding pushpins?

CSUNRAE

Can you please tell me how you can find nearby places using MapPoint web services given the current virtual earth map view

My problem is that i need to display some information on the current map view like schools, hotels, parks and stuffs, how can I achieve this with Mappoint and get data about a specific area.

Thanks,

Csun






Re: Is it possible to find places without adding pushpins?

ChrisMcCabe

First of all, I would wait until version 5 of Virtual Earth is released with documentation (tomorrow I think - April 27, 2007). They may have added the functionality you need with any luck.

But if you still need or want to use MapPoint, you must do the following:

1. Get a MapPoint account. Normally you must pay for this. I'm not sure if there is a free version or not.

2. From your web page, you must make a call to your server with the coordinates of the current view of the map. You can get this with the GetMapView method of the map control.

3. From your server, make a call to the MapPoint FindService using the findNearby method. This method takes a center and a radius, so the Lat/Long rectangle from the map must be converted to a center and a radius. Other arguments include the data source to use and the type of place you are searching for.

4. Send the results back to your web page to be added to the map.

That is the basic process. There is a lot of extra code that needs to be added to accomplish this. Hopefully VirtualEarth V5 will do it.




Re: Is it possible to find places without adding pushpins?

CSUNRAE

How do you know version 5 of Virtual Earth will be released tomorrow

Anyhow,

Do you have any samples for findNearby, basically I don't want a radius search I want a search within the current map view

Thanks

Csun






Re: Is it possible to find places without adding pushpins?

ChrisMcCabe

How do you know version 5 of Virtual Earth will be released tomorrow

Microsoft told me so. It is actually already released, just change v4 to v5 in the URL to the Javascript and you have it. The documentation is scheduled for release tomorrow.

Do you have any samples for findNearby, basically I don't want a radius search I want a search within the current map view

I don't have anything that would be particularly useful because it is very specialized. But take a look at the documentation and you will find some simple examples:

http://msdn2.microsoft.com/en-us/library/aa492582.aspx


Note that findNearby only works by radius, not rectangular area, so you will have to figure out the proper radius to cover your map area and possibly filter the results if you want only those within your map area and nothing more.




Re: Is it possible to find places without adding pushpins?

CSUNRAE

I don't see anywhere that it will be releasing today, where did you find out or do you have the documentation URL for V5




Re: Is it possible to find places without adding pushpins?

ChrisMcCabe

In case you haven't already noticed, it was released as I said.
You can view the documentation at:

http://dev.live.com/virtualearth/sdk/

although it seems to be a mix of v4 and v5 at the moment. You can go directly to the MSDN docs here:

http://msdn2.microsoft.com/en-us/library/bb412546.aspx




Re: Is it possible to find places without adding pushpins?

CSUNRAE

Thank you I already checked that.

But now I have new version new issues LOL

Did you play with the ShowDetailOnMouseOver and OnMouseOverCallback in Version 5






Re: Is it possible to find places without adding pushpins?

Fred Chateau

Chris,

Did you see anything in the v5 documentation that addresses this issue

Also, would you kindly confirm for me that I'm reading the right thread if I need to add more than 20 POI pushpins to a map view

Regards,

Fred





Re: Is it possible to find places without adding pushpins?

ChrisMcCabe

If you want more than 20 POI pushpins, you need to make multiple calls to the Find method. With the first call, you set startIndex to 0 and numberOfResults to 20. In your callback function, if the HasMore flag is true, you make another call with startIndex = 20. Keep incrementing startIndex by 20 with every call until the HasMore flag is false, and you will have all the results. There may be a limit to the total number possible, so you may not actually get everything. In MapPoint the total limit is 500, but I don't see it stated in the VirtualEarth docs. You probably want some upper bound so you don't lock up the browser trying to add 100000 pushpins.

The Find functionality in VirtualEarth is very limited compared to what you can do with MapPoint, but it may be all you need if you are just searching for specific businesses.




Re: Is it possible to find places without adding pushpins?

ChrisMcCabe

CSUNRAE -

The ShowDetailOnMouseOver and OnMouseOverCallback have been replaced in Version 5. (Actually they still exist, but the documented method of doing things is different).

The OnMouseOverCallback is set by calling the AttachEvent method on the VEMap control for the "onmouseover" event. If you return true from your callback, the default popup will not occur, so ShowDetailOnMouseOver is no longer needed.

The parameters to the callback are different from before, and the onmouseover event is generated not only for pushpins, but for the map itself. The elementID property on the event that is passed to the callback will be null if it is a mouseover event on the map. It will contain a string ID for pushpins. You can call the GetShapeByID method on the map to get the actual pushpin (or shape) that the mouse is over.

You also need to replace your calls to AddPushpin with AddShape. The parameters are completely different so you will have to work through that. I think it is a bit more flexible now than before when you are trying to do a lot of customization. I was able to drop some of my ugliest hacks.